aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-31 12:15:57 +0800
committerGitHub <noreply@github.com>2018-10-31 12:15:57 +0800
commit43a5264814bf318e6bd133fb0df51351f0811ddb (patch)
treeb66dd74e4be1c627afb5b56c84f5c740f21a9d33
parent07d0ca50dcb8b4284e53093ff20ad9d5bebaec7d (diff)
downloaddexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.tar
dexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.tar.gz
dexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.tar.bz2
dexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.tar.lz
dexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.tar.xz
dexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.tar.zst
dexon-consensus-43a5264814bf318e6bd133fb0df51351f0811ddb.zip
core: fix NotifyRoundHeight is not called when processing blocks
- also add missing logs when calling Application.BlockDelivered.
-rw-r--r--core/consensus.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 938337f..394ae36 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -910,6 +910,20 @@ func (con *Consensus) preProcessBlock(b *types.Block) (err error) {
return
}
+// deliverBlock deliver a block to application layer.
+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.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++
+ }
+}
+
// processBlock is the entry point to submit one block to a Consensus instance.
func (con *Consensus) processBlock(block *types.Block) (err error) {
if err = con.db.Put(*block); err != nil && err != blockdb.ErrBlockExists {
@@ -936,8 +950,7 @@ func (con *Consensus) processBlock(block *types.Block) (err error) {
panic(err)
}
con.cfgModule.untouchTSigHash(b.Hash)
- // TODO(mission): clone types.FinalizationResult
- con.app.BlockDelivered(b.Hash, b.Finalization)
+ con.deliverBlock(b)
}
if err = con.lattice.PurgeBlocks(deliveredBlocks); err != nil {
return
@@ -966,14 +979,7 @@ func (con *Consensus) processFinalizedBlock(block *types.Block) (err error) {
}
err = nil
}
- con.app.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++
- }
+ con.deliverBlock(b)
}
}
return