aboutsummaryrefslogtreecommitdiffstats
path: root/core/genesis.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-01-13 00:13:49 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:56 +0800
commit7bf5e2205a49a500672ff7415921aa6659c46611 (patch)
tree15fe942ad326e76eda16bda1dd327a6b38deb6a1 /core/genesis.go
parent9bec0c39ad006b5652c587571c2b2411b84a7551 (diff)
downloaddexon-7bf5e2205a49a500672ff7415921aa6659c46611.tar
dexon-7bf5e2205a49a500672ff7415921aa6659c46611.tar.gz
dexon-7bf5e2205a49a500672ff7415921aa6659c46611.tar.bz2
dexon-7bf5e2205a49a500672ff7415921aa6659c46611.tar.lz
dexon-7bf5e2205a49a500672ff7415921aa6659c46611.tar.xz
dexon-7bf5e2205a49a500672ff7415921aa6659c46611.tar.zst
dexon-7bf5e2205a49a500672ff7415921aa6659c46611.zip
core: vm: add totalSupply and totalStaked in the governance contract (#144)
Add totalSupply and totalStaked in the governance contract for the preperation of DEXON cryptoeconomics 4.0. Also removed the unstaked variable in node info and improve tests for delegate/undeleate.
Diffstat (limited to 'core/genesis.go')
-rw-r--r--core/genesis.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/genesis.go b/core/genesis.go
index 38216361f..0948569f1 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -265,6 +265,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db))
govStateHelper := vm.GovernanceStateHelper{StateDB: statedb}
+ totalSupply := big.NewInt(0)
totalStaked := big.NewInt(0)
for addr, account := range g.Alloc {
@@ -281,6 +282,8 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
for key, value := range account.Storage {
statedb.SetState(addr, key, value)
}
+
+ totalSupply = new(big.Int).Add(totalSupply, account.Balance)
}
// For DEXON consensus genesis staking.
@@ -316,6 +319,9 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
// Governance configuration.
govStateHelper.UpdateConfiguration(g.Config.Dexcon)
+
+ // Set totalSupply.
+ govStateHelper.IncTotalSupply(totalSupply)
}
root := statedb.IntermediateRoot(false)