aboutsummaryrefslogtreecommitdiffstats
path: root/core/genesis.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-02-25 19:35:06 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:57 +0800
commitb708ec0f082d431dfe6d56882d58043811647ac7 (patch)
tree575195174be8546146d64b79760288b5f5a8e7b4 /core/genesis.go
parente83bcc1097d49b46b79131e546f1270b9192cc05 (diff)
downloaddexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.gz
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.bz2
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.lz
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.xz
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.zst
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.zip
core: vm: flatten governance
Diffstat (limited to 'core/genesis.go')
-rw-r--r--core/genesis.go25
1 files changed, 3 insertions, 22 deletions
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.