aboutsummaryrefslogtreecommitdiffstats
path: root/core/agreement-mgr.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-12-07 18:02:59 +0800
committerGitHub <noreply@github.com>2018-12-07 18:02:59 +0800
commit1b352d9e52839c8b6c316c2601d08c91c995d8f0 (patch)
tree32aff3397d61b0e6f5e2d6f407ec5ab3a69311d8 /core/agreement-mgr.go
parenta63e0d313300fc85eba8254963800a312fb14e9b (diff)
downloadtangerine-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.gz
tangerine-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.zst
tangerine-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.zip
core: fix bugs found when node-set is not equal to notary-set (#362)
Diffstat (limited to 'core/agreement-mgr.go')
-rw-r--r--core/agreement-mgr.go27
1 files changed, 18 insertions, 9 deletions
diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go
index d3a0af2..c95f913 100644
--- a/core/agreement-mgr.go
+++ b/core/agreement-mgr.go
@@ -298,7 +298,7 @@ func (mgr *agreementMgr) runBA(initRound uint64, chainID uint32) {
// Check if this routine needs to awake in this round and prepare essential
// variables when yes.
- checkRound := func() (awake bool) {
+ checkRound := func() (isNotary, isDisabled bool) {
defer func() {
currentRound = nextRound
nextRound++
@@ -318,7 +318,8 @@ func (mgr *agreementMgr) runBA(initRound uint64, chainID uint32) {
roundEndTime = config.beginTime.Add(config.roundInterval)
// Check if this chain handled by this routine included in this round.
if chainID >= config.numChains {
- return false
+ isDisabled = true
+ return
}
// Check if this node in notary set of this chain in this round.
nodeSet, err := mgr.cache.GetNodeSet(nextRound)
@@ -329,7 +330,18 @@ func (mgr *agreementMgr) runBA(initRound uint64, chainID uint32) {
setting.notarySet = nodeSet.GetSubSet(
int(config.notarySetSize),
types.NewNotarySetTarget(config.crs, chainID))
- _, awake = setting.notarySet[mgr.ID]
+ _, isNotary = setting.notarySet[mgr.ID]
+ if isNotary {
+ mgr.logger.Info("selected as notary set",
+ "ID", mgr.ID,
+ "round", nextRound,
+ "chainID", chainID)
+ } else {
+ mgr.logger.Info("not selected as notary set",
+ "ID", mgr.ID,
+ "round", nextRound,
+ "chainID", chainID)
+ }
// Setup ticker
if tickDuration != config.lambdaBA {
if setting.ticker != nil {
@@ -348,12 +360,9 @@ Loop:
default:
}
now := time.Now().UTC()
- if !checkRound() {
- if now.After(roundEndTime) {
- // That round is passed.
- continue Loop
- }
- // Sleep until next checkpoint.
+ var isDisabled bool
+ setting.recv.isNotary, isDisabled = checkRound()
+ if isDisabled {
select {
case <-mgr.ctx.Done():
break Loop