aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-28 13:28:01 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:59 +0800
commit08c893f4942ea84ed13ecdd6058bcf39585a4566 (patch)
tree3d0b2e5741ad8dc007fc8e3f9dd93b0f1bc8ce19
parent0c63646ca8b06bb527737cd6e2a7fe58f169efff (diff)
downloaddexon-08c893f4942ea84ed13ecdd6058bcf39585a4566.tar.gz
dexon-08c893f4942ea84ed13ecdd6058bcf39585a4566.tar.zst
dexon-08c893f4942ea84ed13ecdd6058bcf39585a4566.zip
core: vm: update set size on node info change (#307)
* core: vm: update set size on node info change * fix typo
-rw-r--r--core/vm/oracle_contracts.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index b148bca1f..dc09df194 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -456,6 +456,9 @@ func (s *GovernanceState) UpdateNode(index *big.Int, n *nodeInfo) {
// UnstakedAt.
loc = new(big.Int).Add(elementBaseLoc, big.NewInt(9))
s.setStateBigInt(loc, n.UnstakedAt)
+
+ // Update set size.
+ s.CalNotarySetSize()
}
func (s *GovernanceState) PopLastNode() {
// Decrease length by 1.
@@ -1053,6 +1056,7 @@ func (s *GovernanceState) UpdateConfigurationRaw(cfg *rawConfigStruct) {
s.setStateBigInt(big.NewInt(minBlockIntervalLoc), cfg.MinBlockInterval)
s.SetFineValues(cfg.FineValues)
+ // Calculate set size.
s.CalNotarySetSize()
}
@@ -1611,8 +1615,6 @@ func (g *GovernanceContract) register(
if value.Cmp(big.NewInt(0)) > 0 {
g.state.IncTotalStaked(value)
g.state.emitStaked(caller, value)
-
- g.state.CalNotarySetSize()
}
return g.useGas(GovernanceActionGasCost)
}
@@ -1641,8 +1643,6 @@ func (g *GovernanceContract) stake() ([]byte, error) {
g.state.IncTotalStaked(value)
g.state.emitStaked(caller, value)
- g.state.CalNotarySetSize()
-
return g.useGas(GovernanceActionGasCost)
}
@@ -1677,8 +1677,6 @@ func (g *GovernanceContract) unstake(amount *big.Int) ([]byte, error) {
g.state.DecTotalStaked(amount)
g.state.emitUnstaked(caller, amount)
- g.state.CalNotarySetSize()
-
return g.useGas(GovernanceActionGasCost)
}
@@ -1757,8 +1755,6 @@ func (g *GovernanceContract) payFine(nodeAddr common.Address) ([]byte, error) {
g.state.emitFinePaid(nodeAddr, g.contract.Value())
- g.state.CalNotarySetSize()
-
return g.useGas(GovernanceActionGasCost)
}