aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-11-05 13:58:18 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:17 +0800
commit0542a6a1b13c3c1235f68a2d0cca23976c241ca9 (patch)
tree6294dc62ee8c19e09d4592915d9c843472d24c77 /vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
parent23fc54de4f886978578207acc15f469abecc46b7 (diff)
downloadgo-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.tar
go-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.tar.gz
go-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.tar.bz2
go-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.tar.lz
go-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.tar.xz
go-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.tar.zst
go-tangerine-0542a6a1b13c3c1235f68a2d0cca23976c241ca9.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.go27
1 files changed, 18 insertions, 9 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 29d4aa2c8..2eed101c7 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
@@ -71,11 +71,11 @@ type consensusBAReceiver struct {
}
func (recv *consensusBAReceiver) ProposeVote(vote *types.Vote) {
+ if err := recv.agreementModule.prepareVote(vote); err != nil {
+ recv.consensus.logger.Error("Failed to prepare vote", "error", err)
+ return
+ }
go func() {
- if err := recv.agreementModule.prepareVote(vote); err != nil {
- recv.consensus.logger.Error("Failed to prepare vote", "error", err)
- return
- }
if err := recv.agreementModule.processVote(vote); err != nil {
recv.consensus.logger.Error("Failed to process vote", "error", err)
return
@@ -336,6 +336,7 @@ func NewConsensus(
ID,
recv,
gov,
+ nodeSetCache,
logger)
recv.cfgModule = cfgModule
// Construct Consensus instance.
@@ -393,6 +394,9 @@ func NewConsensus(
// Run starts running DEXON Consensus.
func (con *Consensus) Run(initBlock *types.Block) {
+ con.logger.Debug("Calling Governance.NotifyRoundHeight for genesis rounds",
+ "block", initBlock)
+ notifyGenesisRounds(initBlock, con.gov)
// Setup context.
con.ctx, con.ctxCancel = context.WithCancel(context.Background())
con.ccModule.init(initBlock)
@@ -430,7 +434,10 @@ func (con *Consensus) Run(initBlock *types.Block) {
for {
<-con.tickerObj.Tick()
for _, tick := range ticks {
- go func(tick chan struct{}) { tick <- struct{}{} }(tick)
+ select {
+ case tick <- struct{}{}:
+ default:
+ }
}
}
}
@@ -926,9 +933,12 @@ func (con *Consensus) deliverBlock(b *types.Block) {
// TODO(mission): clone types.FinalizationResult
con.logger.Debug("Calling Application.BlockDelivered", "block", b)
con.app.BlockDelivered(b.Hash, b.Position, b.Finalization)
- if b.Position.Round+2 == con.roundToNotify {
+ if b.Position.Round+roundShift == con.roundToNotify {
// Only the first block delivered of that round would
// trigger this noitification.
+ con.logger.Debug("Calling Governance.NotifyRoundHeight",
+ "round", con.roundToNotify,
+ "height", b.Finalization.Height)
con.gov.NotifyRoundHeight(
con.roundToNotify, b.Finalization.Height)
con.roundToNotify++
@@ -1002,10 +1012,9 @@ func (con *Consensus) prepareBlock(b *types.Block,
if err = con.lattice.PrepareBlock(b, proposeTime); err != nil {
return
}
- // TODO(mission): decide CRS by block's round, which could be determined by
- // block's info (ex. position, timestamp).
con.logger.Debug("Calling Governance.CRS", "round", 0)
- if err = con.authModule.SignCRS(b, con.gov.CRS(0)); err != nil {
+ if err =
+ con.authModule.SignCRS(b, con.gov.CRS(b.Position.Round)); err != nil {
return
}
return