From b708ec0f082d431dfe6d56882d58043811647ac7 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Mon, 25 Feb 2019 19:35:06 +0800 Subject: core: vm: flatten governance --- core/genesis.go | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'core/genesis.go') diff --git a/core/genesis.go b/core/genesis.go index ff4d9762a..f6935830c 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -33,7 +33,6 @@ import ( "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" "github.com/dexon-foundation/dexon/core/vm" - "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/log" "github.com/dexon-foundation/dexon/params" @@ -265,7 +264,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block { db = ethdb.NewMemDatabase() } statedb, _ := state.New(common.Hash{}, state.NewDatabase(db)) - govStateHelper := vm.GovernanceStateHelper{StateDB: statedb} + govStateHelper := vm.GovernanceState{StateDB: statedb} totalSupply := big.NewInt(0) totalStaked := big.NewInt(0) @@ -309,26 +308,8 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block { } } - if g.Config.Dexcon.NextHalvingSupply.Cmp(totalSupply) <= 0 { - panic(fmt.Sprintf("invalid genesis found, totalSupply: %s, nextHavlingSupply: %s", - totalSupply, g.Config.Dexcon.NextHalvingSupply)) - } - - // Genesis CRS. - crs := crypto.Keccak256Hash([]byte(g.Config.Dexcon.GenesisCRSText)) - govStateHelper.PushCRS(crs) - - // Round 0 height. - govStateHelper.PushRoundHeight(big.NewInt(0)) - - // Owner. - govStateHelper.SetOwner(g.Config.Dexcon.Owner) - - // Governance configuration. - govStateHelper.UpdateConfiguration(g.Config.Dexcon) - - // Set totalSupply. - govStateHelper.IncTotalSupply(totalSupply) + // Initialize governance. + govStateHelper.Initialize(g.Config.Dexcon, totalSupply) } // Set oracle contract. -- cgit v1.2.3