aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-23 14:29:52 +0800
committerGitHub <noreply@github.com>2018-10-23 14:29:52 +0800
commite79e91c31eaa08e69def8b204901004b3b85e828 (patch)
tree493cbf42ce060ca3e251e85682a1157938640907 /core
parente5aa1799c256a1ae56cc4b7ee0a54f94cb084687 (diff)
downloaddexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.tar
dexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.tar.gz
dexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.tar.bz2
dexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.tar.lz
dexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.tar.xz
dexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.tar.zst
dexon-consensus-e79e91c31eaa08e69def8b204901004b3b85e828.zip
core: notify fullnode to snapshot configs when round change. (#243)
Diffstat (limited to 'core')
-rw-r--r--core/consensus.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 18294ef..c7bef4b 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -253,14 +253,15 @@ type Consensus struct {
tickerObj Ticker
// Misc.
- dMoment time.Time
- nodeSetCache *NodeSetCache
- round uint64
- lock sync.RWMutex
- ctx context.Context
- ctxCancel context.CancelFunc
- event *common.Event
- logger common.Logger
+ dMoment time.Time
+ nodeSetCache *NodeSetCache
+ round uint64
+ roundToNotify uint64
+ lock sync.RWMutex
+ ctx context.Context
+ ctxCancel context.CancelFunc
+ event *common.Event
+ logger common.Logger
}
// NewConsensus construct an Consensus instance.
@@ -276,6 +277,8 @@ func NewConsensus(
// TODO(w): load latest blockHeight from DB, and use config at that height.
var (
round uint64
+ // round 0 and 1 are decided at beginning.
+ roundToNotify = round + 2
)
logger.Debug("Calling Governance.Configuration", "round", round)
config := gov.Configuration(round)
@@ -330,6 +333,7 @@ func NewConsensus(
authModule: authModule,
event: common.NewEvent(),
logger: logger,
+ roundToNotify: roundToNotify,
}
con.baModules = make([]*agreement, config.NumChains)
@@ -875,6 +879,13 @@ func (con *Consensus) processFinalizedBlock(block *types.Block) (err error) {
err = nil
}
con.nbModule.BlockDelivered(b.Hash, b.Finalization)
+ if b.Position.Round+2 == con.roundToNotify {
+ // Only the first block delivered of that round would
+ // trigger this noitification.
+ con.gov.NotifyRoundHeight(
+ con.roundToNotify, b.Finalization.Height)
+ con.roundToNotify++
+ }
}
}
return