diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-19 18:52:38 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | 35c4bfe0326eecc3d2feeb592b6a0057038ebb3e (patch) | |
tree | 371e357b2135fc5fb3f3e1609fae31f015c1fc6b /dex | |
parent | 84c85fb081a0a821077e94c66beb391fa6fa86c9 (diff) | |
download | dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.tar dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.tar.gz dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.tar.bz2 dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.tar.lz dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.tar.xz dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.tar.zst dexon-35c4bfe0326eecc3d2feeb592b6a0057038ebb3e.zip |
consensus: dexcon: fetch config from state
Diffstat (limited to 'dex')
-rw-r--r-- | dex/app.go | 1 | ||||
-rw-r--r-- | dex/backend.go | 8 | ||||
-rw-r--r-- | dex/config.go | 5 | ||||
-rw-r--r-- | dex/governance.go | 8 |
4 files changed, 15 insertions, 7 deletions
diff --git a/dex/app.go b/dex/app.go index 317711e94..ab23301d5 100644 --- a/dex/app.go +++ b/dex/app.go @@ -223,6 +223,7 @@ func (d *DexconApp) BlockDelivered(blockHash coreCommon.Hash, result coreTypes.F Number: new(big.Int).SetUint64(result.Height), Time: big.NewInt(result.Timestamp.Unix()), Coinbase: common.BytesToAddress(block.ProposerID.Bytes()), + Position: block.Position, WitnessHeight: block.Witness.Height, WitnessRoot: witnessData.Root, WitnessReceiptHash: witnessData.ReceiptHash, diff --git a/dex/backend.go b/dex/backend.go index 4151fa8e2..10f74dafd 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -110,6 +110,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { } rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion) } + engine := dexcon.New() + dex := &Dexon{ config: config, chainDb: chainDb, @@ -121,7 +123,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { bloomRequests: make(chan chan *bloombits.Retrieval), bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms), blockdb: db, - engine: dexcon.New(chainConfig.Dexcon), + engine: engine, } var ( @@ -154,9 +156,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { } dex.APIBackend.gpo = gasprice.NewOracle(dex.APIBackend, gpoParams) + // Dexcon related objects. dex.governance = NewDexconGovernance(dex.APIBackend, dex.chainConfig, config.PrivateKey) dex.app = NewDexconApp(dex.txPool, dex.blockchain, dex.governance, chainDb, config, vmConfig) + // Set config fetcher so engine can fetch current system configuration from state. + engine.SetConfigFetcher(dex.governance) + pm, err := NewProtocolManager(dex.chainConfig, config.SyncMode, config.NetworkId, dex.eventMux, dex.txPool, dex.engine, dex.blockchain, chainDb, dex.governance) diff --git a/dex/config.go b/dex/config.go index 507ccf5e3..4d76ec8fe 100644 --- a/dex/config.go +++ b/dex/config.go @@ -25,7 +25,6 @@ import ( "runtime" "time" - "github.com/dexon-foundation/dexon/consensus/dexcon" "github.com/dexon-foundation/dexon/core" "github.com/dexon-foundation/dexon/dex/gasprice" "github.com/dexon-foundation/dexon/eth/downloader" @@ -35,7 +34,6 @@ import ( // DefaultConfig contains default settings for use on the Ethereum main net. var DefaultConfig = Config{ SyncMode: downloader.FastSync, - Dexcon: dexcon.Config{}, NetworkId: 1, LightPeers: 100, DatabaseCache: 768, @@ -102,9 +100,6 @@ type Config struct { GasCeil uint64 GasLimitTolerance uint64 - // Dexcon options - Dexcon dexcon.Config - // Transaction pool options TxPool core.TxPoolConfig diff --git a/dex/governance.go b/dex/governance.go index 4ec69c2d6..50ab7ee14 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -79,7 +79,13 @@ func (d *DexconGovernance) getGovStateAtRound(round uint64) *vm.GovernanceStateH return &vm.GovernanceStateHelper{state} } -// Configuration return the total ordering K constant. +// DexconConfiguration return raw config in state. +func (d *DexconGovernance) DexconConfiguration(round uint64) *params.DexconConfig { + s := d.getGovStateAtRound(round) + return s.Configuration() +} + +// Configuration returns the system configuration for consensus core to use. func (d *DexconGovernance) Configuration(round uint64) *coreTypes.Config { s := d.getGovStateAtRound(round) c := s.Configuration() |