diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-19 18:52:38 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:23:39 +0800 |
commit | 0e12c9284efdf72a376f75f180bac7968d6fb382 (patch) | |
tree | 1b06f8f9483bff246dbeba12c7445780a595b21a /dex | |
parent | 93563f41410b964454f23229cfabe1ec1ba735f5 (diff) | |
download | go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.tar go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.tar.gz go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.tar.bz2 go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.tar.lz go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.tar.xz go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.tar.zst go-tangerine-0e12c9284efdf72a376f75f180bac7968d6fb382.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 7a23ba80b..2f6d8a8e5 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 a3b682de0..5eff28022 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() |