aboutsummaryrefslogtreecommitdiffstats
path: root/core/utils.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-18 11:39:14 +0800
committerGitHub <noreply@github.com>2019-01-18 11:39:14 +0800
commit9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb (patch)
tree26fa5ba54878b52dc6c8bb610428cdb8b84baba7 /core/utils.go
parentc5b303f4d143631fb565d4ec8ff3bcc609a4ffd3 (diff)
downloaddexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.tar
dexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.tar.gz
dexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.tar.bz2
dexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.tar.lz
dexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.tar.xz
dexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.tar.zst
dexon-consensus-9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb.zip
core: Fix stuffs (#422)
* core: reduce syncing ba msg * core: fix checking period of agreement result
Diffstat (limited to 'core/utils.go')
-rw-r--r--core/utils.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/utils.go b/core/utils.go
index 3b1069e..8579e6e 100644
--- a/core/utils.go
+++ b/core/utils.go
@@ -32,6 +32,20 @@ import (
"github.com/dexon-foundation/dexon-consensus/core/utils"
)
+// Errors for utils.
+var (
+ ErrIncorrectVoteBlockHash = fmt.Errorf(
+ "incorrect vote block hash")
+ ErrIncorrectVoteType = fmt.Errorf(
+ "incorrect vote type")
+ ErrIncorrectVotePosition = fmt.Errorf(
+ "incorrect vote position")
+ ErrIncorrectVoteProposer = fmt.Errorf(
+ "incorrect vote proposer")
+ ErrIncorrectVotePeriod = fmt.Errorf(
+ "incorrect vote period")
+)
+
// NodeSetCache is type alias to avoid fullnode compile error when moving
// it to core/utils package.
type NodeSetCache = utils.NodeSetCache
@@ -161,10 +175,14 @@ func VerifyAgreementResult(
}
voted := make(map[types.NodeID]struct{}, len(notarySet))
voteType := res.Votes[0].Type
+ votePeriod := res.Votes[0].Period
if voteType != types.VoteFast && voteType != types.VoteCom {
return ErrIncorrectVoteType
}
for _, vote := range res.Votes {
+ if vote.Period != votePeriod {
+ return ErrIncorrectVotePeriod
+ }
if res.IsEmptyBlock {
if (vote.BlockHash != common.Hash{}) {
return ErrIncorrectVoteBlockHash