diff options
author | Mission Liao <mission.liao@dexon.org> | 2019-04-10 10:35:42 +0800 |
---|---|---|
committer | Mission Liao <mission.liao@dexon.org> | 2019-04-15 14:41:19 +0800 |
commit | 46dab5936d7a9e52f42edaa926a1adb6dcafd81b (patch) | |
tree | a9039d3f9baac5950751717053a4d3f4c4e4f91c | |
parent | 2a1d46ebb1a0e620edfae791b72c72b7d212b06a (diff) | |
download | dexon-consensus-46dab5936d7a9e52f42edaa926a1adb6dcafd81b.tar.gz dexon-consensus-46dab5936d7a9e52f42edaa926a1adb6dcafd81b.tar.zst dexon-consensus-46dab5936d7a9e52f42edaa926a1adb6dcafd81b.zip |
Add Newer method to types.Vote
-rw-r--r-- | core/types/vote.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/types/vote.go b/core/types/vote.go index 8bb27c1..d935e7d 100644 --- a/core/types/vote.go +++ b/core/types/vote.go @@ -115,3 +115,9 @@ func (v *Vote) Clone() *Vote { Signature: v.Signature.Clone(), } } + +// Newer return true when the (position, period) of other vote is older than us. +func (v Vote) Newer(other Vote) bool { + return v.Position.Newer(other.Position) || + (v.Position.Equal(other.Position) && v.Period > other.Period) +} |