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/lattice.go | |
parent | 490fa1e9ce2b661e4c8b612bd53f20123346353b (diff) | |
download | tangerine-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar tangerine-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.gz tangerine-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.bz2 tangerine-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.lz tangerine-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.xz tangerine-consensus-48f5fdb27e3218e2476b27ae99bcf242533b3bc3.tar.zst tangerine-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/lattice.go')
-rw-r--r-- | core/lattice.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/lattice.go b/core/lattice.go index 18e7ae6..d634650 100644 --- a/core/lattice.go +++ b/core/lattice.go @@ -43,12 +43,14 @@ type Lattice struct { // NewLattice constructs an Lattice instance. func NewLattice( - round uint64, + dMoment time.Time, cfg *types.Config, authModule *Authenticator, app Application, debug Debug, db blockdb.BlockDatabase) (s *Lattice) { + // Create genesis latticeDataConfig. + dataConfig := newGenesisLatticeDataConfig(dMoment, cfg) s = &Lattice{ authModule: authModule, chainNum: cfg.NumChains, @@ -56,13 +58,12 @@ func NewLattice( debug: debug, lastConfig: cfg, pool: newBlockPool(cfg.NumChains), - data: newLatticeData(db, round, newLatticeDataConfig(nil, cfg)), + data: newLatticeData(db, dataConfig), toModule: newTotalOrdering( - round, uint64(cfg.K), uint64(float32(cfg.NumChains-1)*cfg.PhiRatio+1), cfg.NumChains), - ctModule: newConsensusTimestamp(round, cfg.NumChains), + ctModule: newConsensusTimestamp(cfg.NumChains), } return } @@ -75,7 +76,9 @@ func (s *Lattice) PrepareBlock( defer s.lock.RUnlock() b.Timestamp = proposeTime - s.data.prepareBlock(b) + if err = s.data.prepareBlock(b); err != nil { + return + } b.Payload = s.app.PreparePayload(b.Position) b.Witness = s.app.PrepareWitness(b.Witness.Height) if err = s.authModule.SignBlock(b); err != nil { |