aboutsummaryrefslogtreecommitdiffstats
path: root/core/consensus.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-20 14:03:18 +0800
committerGitHub <noreply@github.com>2018-08-20 14:03:18 +0800
commit1e71e263e063adbe7e44d48818f9c74924a2945d (patch)
treeb874d8d4d6cc1d0aa6f106f276f83706361f0878 /core/consensus.go
parentd9ba7986a975615fb10790cfd448c48c89c1a7b3 (diff)
downloaddexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.tar
dexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.tar.gz
dexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.tar.bz2
dexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.tar.lz
dexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.tar.xz
dexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.tar.zst
dexon-consensus-1e71e263e063adbe7e44d48818f9c74924a2945d.zip
core: NotaryAck interfaces. (#67)
Diffstat (limited to 'core/consensus.go')
-rw-r--r--core/consensus.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 3e8f87d..0b4ea62 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -48,8 +48,6 @@ var (
"hash of block is incorrect")
ErrIncorrectSignature = fmt.Errorf(
"signature of block is incorrect")
- ErrIncorrectNotaryAck = fmt.Errorf(
- "compaction chain notary of block is incorrect")
ErrGenesisBlockNotEmpty = fmt.Errorf(
"genesis block should be empty")
)
@@ -204,6 +202,12 @@ func (con *Consensus) ProcessBlock(blockConv types.BlockConverter) (err error) {
}
con.app.DeliverBlock(b.Hash, b.Notary.Timestamp)
}
+ var notaryAck types.NotaryAck
+ notaryAck, err = con.ccModule.prepareNotaryAck(con.prvKey)
+ if err != nil {
+ return
+ }
+ con.app.NotaryAck(notaryAck)
}
return
}
@@ -237,10 +241,6 @@ func (con *Consensus) PrepareBlock(blockConv types.BlockConverter,
if err != nil {
return
}
- err = con.ccModule.prepareBlock(b, con.prvKey)
- if err != nil {
- return
- }
blockConv.SetBlock(b)
return
}
@@ -275,3 +275,19 @@ func (con *Consensus) PrepareGenesisBlock(blockConv types.BlockConverter,
blockConv.SetBlock(b)
return
}
+
+// ProcessNotaryAck is the entry point to submit one notary ack.
+func (con *Consensus) ProcessNotaryAck(notaryAck types.NotaryAck) (err error) {
+ err = con.ccModule.processNotaryAck(notaryAck)
+ return
+}
+
+// NotaryAcks returns the latest NotaryAck received from all other validators.
+func (con *Consensus) NotaryAcks() (
+ notaryAcks map[types.ValidatorID]types.NotaryAck) {
+ notaryAcks = make(map[types.ValidatorID]types.NotaryAck)
+ for k, v := range con.ccModule.notaryAcks() {
+ notaryAcks[k] = v
+ }
+ return
+}