aboutsummaryrefslogtreecommitdiffstats
path: root/core/compaction-chain.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-25 15:47:36 +0800
committerGitHub <noreply@github.com>2018-10-25 15:47:36 +0800
commit233f1e8de99bf2a0023f05d1c67e48cc770621df (patch)
treed60fa19092db7a113ab35d94cae4cddaa91283ce /core/compaction-chain.go
parent98c53bffc1045eb22ef640984088e5e592989593 (diff)
downloadtangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.tar
tangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.tar.gz
tangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.tar.bz2
tangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.tar.lz
tangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.tar.xz
tangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.tar.zst
tangerine-consensus-233f1e8de99bf2a0023f05d1c67e48cc770621df.zip
core: handle round 0 randomness in processFinalizedBlock (#256)
Diffstat (limited to 'core/compaction-chain.go')
-rw-r--r--core/compaction-chain.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/core/compaction-chain.go b/core/compaction-chain.go
index 451cb13..50056a9 100644
--- a/core/compaction-chain.go
+++ b/core/compaction-chain.go
@@ -148,6 +148,11 @@ func (cc *compactionChain) processFinalizedBlock(block *types.Block) {
return
}
+ // Block of round 0 should not have randomness.
+ if block.Position.Round == 0 && len(block.Finalization.Randomness) != 0 {
+ return
+ }
+
cc.lock.Lock()
defer cc.lock.Unlock()
heap.Push(cc.pendingFinalizedBlocks, block)
@@ -191,18 +196,21 @@ func (cc *compactionChain) extractFinalizedBlocks() []*types.Block {
continue
}
round := b.Position.Round
- v, ok, err := cc.tsigVerifier.UpdateAndGet(round)
- if err != nil {
- continue
- }
- if !ok {
- toPending = append(toPending, b)
- continue
- }
- if ok := v.VerifySignature(b.Hash, crypto.Signature{
- Type: "bls",
- Signature: b.Finalization.Randomness}); !ok {
- continue
+ if round != 0 {
+ // Randomness is not available at round 0.
+ v, ok, err := cc.tsigVerifier.UpdateAndGet(round)
+ if err != nil {
+ continue
+ }
+ if !ok {
+ toPending = append(toPending, b)
+ continue
+ }
+ if ok := v.VerifySignature(b.Hash, crypto.Signature{
+ Type: "bls",
+ Signature: b.Finalization.Randomness}); !ok {
+ continue
+ }
}
// Fork resolution: choose block with smaller hash.
if prevBlock.Finalization.Height == b.Finalization.Height {