aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-11 17:04:06 +0800
committerGitHub <noreply@github.com>2018-10-11 17:04:06 +0800
commitf3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c (patch)
tree7922df506e8f508b81dfbfde35ececb6f8b07fdf /core
parenta13f15bf54a2c10e5223779877778da0eebb4855 (diff)
downloaddexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.tar
dexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.tar.gz
dexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.tar.bz2
dexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.tar.lz
dexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.tar.xz
dexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.tar.zst
dexon-consensus-f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c.zip
core: Move BlockConfirmed to Application interface (#192)
When a block is confirmed, all its txs are permitted to be executed. Therefore, exporting this method provides more and earlier information about txs to be executed, and helps application layer to process txs more efficiently.
Diffstat (limited to 'core')
-rw-r--r--core/interfaces.go6
-rw-r--r--core/lattice.go2
-rw-r--r--core/nonblocking.go2
3 files changed, 5 insertions, 5 deletions
diff --git a/core/interfaces.go b/core/interfaces.go
index f4a6cd0..98cbb4d 100644
--- a/core/interfaces.go
+++ b/core/interfaces.go
@@ -37,6 +37,9 @@ type Application interface {
// VerifyBlock verifies if the block is valid.
VerifyBlock(block *types.Block) bool
+ // BlockConfirmed is called when a block is confirmed and added to lattice.
+ BlockConfirmed(blockHash common.Hash)
+
// BlockDelivered is called when a block is add to the compaction chain.
BlockDelivered(block types.Block)
}
@@ -44,9 +47,6 @@ type Application interface {
// Debug describes the application interface that requires
// more detailed consensus execution.
type Debug interface {
- // BlockConfirmed is called when a block is confirmed and added to lattice.
- BlockConfirmed(blockHash common.Hash)
-
// StronglyAcked is called when a block is strongly acked.
StronglyAcked(blockHash common.Hash)
diff --git a/core/lattice.go b/core/lattice.go
index 3ee0b94..6ecb88f 100644
--- a/core/lattice.go
+++ b/core/lattice.go
@@ -153,8 +153,8 @@ func (s *Lattice) ProcessBlock(
// be done here.
if s.debug != nil {
s.debug.StronglyAcked(input.Hash)
- s.debug.BlockConfirmed(input.Hash)
}
+ s.app.BlockConfirmed(input.Hash)
// Purge blocks in pool with the same chainID and lower height.
s.pool.purgeBlocks(input.Position.ChainID, input.Position.Height)
// Replay tips in pool to check their validity.
diff --git a/core/nonblocking.go b/core/nonblocking.go
index 4948a4f..83c2351 100644
--- a/core/nonblocking.go
+++ b/core/nonblocking.go
@@ -94,7 +94,7 @@ func (nb *nonBlocking) run() {
case stronglyAckedEvent:
nb.debug.StronglyAcked(e.blockHash)
case blockConfirmedEvent:
- nb.debug.BlockConfirmed(e.blockHash)
+ nb.app.BlockConfirmed(e.blockHash)
case totalOrderingDeliveredEvent:
nb.debug.TotalOrderingDelivered(e.blockHashes, e.early)
case blockDeliveredEvent: