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-01-14 15:26:57 +0800
commit646d6d4c77e0726d82cb016e12aab8edaccb7e95 (patch)
tree55299e9686dee75ffb400058cc52395ec89bbc5b /core/genesis.go
parent0b6df729bbd9242d29913fd42a3ba8aca079e195 (diff)
downloaddexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.tar
dexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.tar.gz
dexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.tar.bz2
dexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.tar.lz
dexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.tar.xz
dexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.tar.zst
dexon-646d6d4c77e0726d82cb016e12aab8edaccb7e95.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 c1b5466fa..2974d20d1 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -264,6 +264,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 {
@@ -280,6 +281,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.
@@ -315,6 +318,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)