aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-02-27 10:41:01 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:57 +0800
commite83bcc1097d49b46b79131e546f1270b9192cc05 (patch)
treea1af659afd80e3744177637cc06b2f0662a0ced8 /vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go
parent22b38ce74c3da40b7b7f24ada0abdf8d5ba03c64 (diff)
downloaddexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar
dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.gz
dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.bz2
dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.lz
dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.xz
dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.tar.zst
dexon-e83bcc1097d49b46b79131e546f1270b9192cc05.zip
core: sync to latest core (#214)
* vendor: sync to latest core * fix for single chain
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go23
1 files changed, 4 insertions, 19 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go
index 902a55fec..81d23c266 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/position.go
@@ -23,33 +23,22 @@ import (
// Position describes the position in the block lattice of an entity.
type Position struct {
- ChainID uint32 `json:"chain_id"`
- Round uint64 `json:"round"`
- Height uint64 `json:"height"`
+ Round uint64 `json:"round"`
+ Height uint64 `json:"height"`
}
func (pos Position) String() string {
- return fmt.Sprintf("Position{Round:%d Chain:%d Height:%d}",
- pos.Round, pos.ChainID, pos.Height)
+ return fmt.Sprintf("Position{Round:%d Height:%d}", pos.Round, pos.Height)
}
-// Equal checks if two positions are equal, it panics when their chainIDs
-// are different.
+// Equal checks if two positions are equal.
func (pos Position) Equal(other Position) bool {
- if pos.ChainID != other.ChainID {
- panic(fmt.Errorf("unexpected chainID %d, should be %d",
- other.ChainID, pos.ChainID))
- }
return pos.Round == other.Round && pos.Height == other.Height
}
// Newer checks if one block is newer than another one on the same chain.
// If two blocks on different chain compared by this function, it would panic.
func (pos Position) Newer(other Position) bool {
- if pos.ChainID != other.ChainID {
- panic(fmt.Errorf("unexpected chainID %d, should be %d",
- other.ChainID, pos.ChainID))
- }
return pos.Round > other.Round ||
(pos.Round == other.Round && pos.Height > other.Height)
}
@@ -57,10 +46,6 @@ func (pos Position) Newer(other Position) bool {
// Older checks if one block is older than another one on the same chain.
// If two blocks on different chain compared by this function, it would panic.
func (pos Position) Older(other Position) bool {
- if pos.ChainID != other.ChainID {
- panic(fmt.Errorf("unexpected chainID %d, should be %d",
- other.ChainID, pos.ChainID))
- }
return pos.Round < other.Round ||
(pos.Round == other.Round && pos.Height < other.Height)
}