From 646d6d4c77e0726d82cb016e12aab8edaccb7e95 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Sun, 13 Jan 2019 00:13:49 +0800 Subject: 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. --- core/genesis.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core/genesis.go') 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) -- cgit v1.2.3