aboutsummaryrefslogtreecommitdiffstats
path: root/core/types
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-27 10:13:09 +0800
committerGitHub <noreply@github.com>2018-10-27 10:13:09 +0800
commit47c29f1bc537f2108755f943e190a9f9a58c1ac0 (patch)
tree8f6185f05ead65f2db33313fb750988199c23482 /core/types
parent8aec64250e6d9dbdc263f11716a7575c3f3af789 (diff)
downloaddexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.tar
dexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.tar.gz
dexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.tar.bz2
dexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.tar.lz
dexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.tar.xz
dexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.tar.zst
dexon-consensus-47c29f1bc537f2108755f943e190a9f9a58c1ac0.zip
core: Remove atomic (#266)
Diffstat (limited to 'core/types')
-rw-r--r--core/types/position.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/core/types/position.go b/core/types/position.go
index d821d16..8e7e852 100644
--- a/core/types/position.go
+++ b/core/types/position.go
@@ -18,15 +18,9 @@
package types
import (
- "errors"
"fmt"
)
-// ErrComparePositionOnDifferentChains raised when attempting to
-// compare two positions with different chain ID.
-var ErrComparePositionOnDifferentChains = errors.New(
- "position on different chain")
-
// Position describes the position in the block lattice of an entity.
type Position struct {
ChainID uint32 `json:"chain_id"`
@@ -42,7 +36,8 @@ func (pos *Position) String() string {
// are different.
func (pos *Position) Equal(other *Position) bool {
if pos.ChainID != other.ChainID {
- panic(ErrComparePositionOnDifferentChains)
+ panic(fmt.Errorf("unexpected chainID %d, should be %d",
+ other.ChainID, pos.ChainID))
}
return pos.Round == other.Round && pos.Height == other.Height
}
@@ -51,7 +46,8 @@ func (pos *Position) Equal(other *Position) bool {
// 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(ErrComparePositionOnDifferentChains)
+ 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)
@@ -61,7 +57,8 @@ func (pos *Position) Newer(other *Position) bool {
// 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(ErrComparePositionOnDifferentChains)
+ 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)