diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-02-25 19:35:06 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 4ce8adb190ae3351a507be54f38afa6b47ce18a3 (patch) | |
tree | 585b6f4bb5ee06b0fdab0f8e68f34e15b6ae0fed /core/genesis.go | |
parent | 0ac79d780ba63c574d648552f887c9411fdd76fe (diff) | |
download | dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.gz dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.bz2 dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.lz dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.xz dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.zst dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.zip |
core: vm: flatten governance
Diffstat (limited to 'core/genesis.go')
-rw-r--r-- | core/genesis.go | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/core/genesis.go b/core/genesis.go index ea521dc9b..5e91a3020 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. |