aboutsummaryrefslogtreecommitdiffstats
path: root/core/nonblocking-application.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-31 13:34:00 +0800
committerGitHub <noreply@github.com>2018-08-31 13:34:00 +0800
commit18c6a28ff021c9dc643091b5dc420b51183253cf (patch)
tree3017ffcfc03532289b1856f5f9a1a83012eb5d8e /core/nonblocking-application.go
parent123a7ee3bcf96c5bbef2ea16737d1a8e25f5ef30 (diff)
downloaddexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.tar
dexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.tar.gz
dexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.tar.bz2
dexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.tar.lz
dexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.tar.xz
dexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.tar.zst
dexon-consensus-18c6a28ff021c9dc643091b5dc420b51183253cf.zip
Add methods to Application interface. (#86)
Diffstat (limited to 'core/nonblocking-application.go')
-rw-r--r--core/nonblocking-application.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/nonblocking-application.go b/core/nonblocking-application.go
index 72f63b9..fb25745 100644
--- a/core/nonblocking-application.go
+++ b/core/nonblocking-application.go
@@ -26,6 +26,10 @@ import (
"github.com/dexon-foundation/dexon-consensus-core/core/types"
)
+type blockConfirmedEvent struct {
+ block *types.Block
+}
+
type stronglyAckedEvent struct {
blockHash common.Hash
}
@@ -90,6 +94,8 @@ func (app *nonBlockingApplication) run() {
switch e := event.(type) {
case stronglyAckedEvent:
app.app.StronglyAcked(e.blockHash)
+ case blockConfirmedEvent:
+ app.app.BlockConfirmed(e.block)
case totalOrderingDeliverEvent:
app.app.TotalOrderingDeliver(e.blockHashes, e.early)
case deliverBlockEvent:
@@ -120,6 +126,16 @@ func (app *nonBlockingApplication) PreparePayloads(
return app.app.PreparePayloads(shardID, chainID, height)
}
+// VerifyPayloads cannot be non-blocking.
+func (app *nonBlockingApplication) VerifyPayloads(payloads [][]byte) bool {
+ return true
+}
+
+// BlockConfirmed is called when a block is confirmed and added to lattice.
+func (app *nonBlockingApplication) BlockConfirmed(block *types.Block) {
+ app.addEvent(blockConfirmedEvent{block})
+}
+
// StronglyAcked is called when a block is strongly acked.
func (app *nonBlockingApplication) StronglyAcked(blockHash common.Hash) {
app.addEvent(stronglyAckedEvent{blockHash})