aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-28 18:24:46 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit41193d921118b4bdef5f0a1a5b7349a4c58abe94 (patch)
treef5a274c3d007810064e3ed65e6e52390fb93669e /vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
parent4efc1cf485200000420bd79638139eb5383641ae (diff)
downloadgo-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar
go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.gz
go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.bz2
go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.lz
go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.xz
go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.tar.zst
go-tangerine-41193d921118b4bdef5f0a1a5b7349a4c58abe94.zip
vendor: sync to latest core
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
index 4a95eac6f..6d0f68377 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
@@ -390,14 +390,17 @@ CleanChannelLoop:
}
}
newPos := block.Position
- if block.Position.Height+1 == recv.changeNotaryHeight() {
+ changeNotaryHeight := recv.changeNotaryHeight()
+ if block.Position.Height+1 >= changeNotaryHeight {
+ recv.consensus.logger.Info("Round will change",
+ "block", block,
+ "change-height", changeNotaryHeight)
newPos.Round++
recv.updateRound(newPos.Round)
}
currentRound := recv.round()
- changeNotaryHeight := recv.changeNotaryHeight()
if block.Position.Height > changeNotaryHeight &&
- block.Position.Round <= currentRound {
+ block.Position.Round < currentRound {
panic(fmt.Errorf(
"round not switch when confirming: %s, %d, should switch at %d, %s",
block, currentRound, changeNotaryHeight, newPos))
@@ -733,7 +736,12 @@ func newConsensusForRound(
}
baConfig := agreementMgrConfig{}
baConfig.from(initRound, initConfig, initCRS)
- baConfig.SetRoundBeginHeight(gov.GetRoundHeight(initRound))
+ // TODO(jimmy): remove -1 after we match the height with fullnode.
+ roundHeight := gov.GetRoundHeight(initRound)
+ if initRound > 0 {
+ roundHeight--
+ }
+ baConfig.SetRoundBeginHeight(roundHeight)
con.baMgr, err = newAgreementMgr(con, baConfig)
if err != nil {
panic(err)
@@ -804,15 +812,13 @@ func (con *Consensus) prepare(initBlock *types.Block) (err error) {
// Register round event handler to update BA and BC modules.
con.roundEvent.Register(func(evts []utils.RoundEventParam) {
defer elapse("append-config", evts[len(evts)-1])()
- // Always updates newer configs to the later modules first in the flow.
+ // Always updates newer configs to the later modules first in the data
+ // flow.
if err := con.bcModule.notifyRoundEvents(evts); err != nil {
panic(err)
}
- // The init config is provided to baModule when construction.
- if evts[len(evts)-1].BeginHeight != con.gov.GetRoundHeight(initRound) {
- if err := con.baMgr.notifyRoundEvents(evts); err != nil {
- panic(err)
- }
+ if err := con.baMgr.notifyRoundEvents(evts); err != nil {
+ panic(err)
}
})
// Register round event handler to reset DKG if the DKG set for next round