diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-10-12 18:59:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-12 18:59:05 +0800 |
commit | 48f5fdb27e3218e2476b27ae99bcf242533b3bc3 (patch) | |
tree | 9926478b8dc6129d67a7da2d6fdfde84b96420c6 /core/consensus.go | |
parent | 490fa1e9ce2b661e4c8b612bd53f20123346353b (diff) | |
download | dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.gz dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.bz2 dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.lz dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.xz dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.zst dexon-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.zip |
core: latticeData supports config change (#190)
* Add test for num of chains changes.
* Return error in latticeData.prepareBlock
* Compare two positions
* Modify chainStatus from height-based to index-based.
* Fix consensus to use round variable
* Remove sanity check in chainStatus
* Fixup: refine sanity check
- verify if round switching is required or not by
chainTip's config.
- make the logic in sanity check more clear
- pospone acking relationship checking, they
are more expensive to check.
Diffstat (limited to 'core/consensus.go')
-rw-r--r-- | core/consensus.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/consensus.go b/core/consensus.go index dcc6f38..90a8f09 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -232,15 +232,15 @@ func NewConsensus( prv crypto.PrivateKey) *Consensus { // TODO(w): load latest blockHeight from DB, and use config at that height. - var round uint64 + var ( + round uint64 + dMoment = time.Now().UTC() + ) config := gov.Configuration(round) - // TODO(w): notarySet is different for each chain, need to write a - // GetNotarySetForChain(nodeSet, chainID, crs) function to get the - // correct notary set for a given chain. nodeSetCache := NewNodeSetCache(gov) crs := gov.CRS(round) // Setup acking by information returned from Governace. - nodes, err := nodeSetCache.GetNodeSet(0) + nodes, err := nodeSetCache.GetNodeSet(round) if err != nil { panic(err) } @@ -253,7 +253,7 @@ func NewConsensus( // Setup nonblocking module. nbModule := newNonBlocking(app, debugApp) // Init lattice. - lattice := NewLattice(round, config, authModule, nbModule, nbModule, db) + lattice := NewLattice(dMoment, config, authModule, nbModule, nbModule, db) // Init configuration chain. ID := types.NewNodeID(prv.PublicKey()) cfgModule := newConfigurationChain( @@ -268,7 +268,7 @@ func NewConsensus( gov) // Register DKG for the initial round. This is a temporary function call for // simulation. - cfgModule.registerDKG(0, int(config.DKGSetSize)/3) + cfgModule.registerDKG(round, int(config.DKGSetSize)/3) // Construct Consensus instance. con := &Consensus{ ID: ID, @@ -279,7 +279,7 @@ func NewConsensus( gov: gov, db: db, network: network, - tickerObj: newTicker(gov, 0, TickerBA), + tickerObj: newTicker(gov, round, TickerBA), dkgReady: sync.NewCond(&sync.Mutex{}), cfgModule: cfgModule, nodeSetCache: nodeSetCache, |