aboutsummaryrefslogtreecommitdiffstats
path: root/core/utils/nodeset-cache.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-12-07 18:02:59 +0800
committerGitHub <noreply@github.com>2018-12-07 18:02:59 +0800
commit1b352d9e52839c8b6c316c2601d08c91c995d8f0 (patch)
tree32aff3397d61b0e6f5e2d6f407ec5ab3a69311d8 /core/utils/nodeset-cache.go
parenta63e0d313300fc85eba8254963800a312fb14e9b (diff)
downloaddexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar
dexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.gz
dexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.bz2
dexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.lz
dexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.xz
dexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.tar.zst
dexon-consensus-1b352d9e52839c8b6c316c2601d08c91c995d8f0.zip
core: fix bugs found when node-set is not equal to notary-set (#362)
Diffstat (limited to 'core/utils/nodeset-cache.go')
-rw-r--r--core/utils/nodeset-cache.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/core/utils/nodeset-cache.go b/core/utils/nodeset-cache.go
index a8f8fe5..6d4f7b0 100644
--- a/core/utils/nodeset-cache.go
+++ b/core/utils/nodeset-cache.go
@@ -27,8 +27,12 @@ import (
)
var (
- // ErrRoundNotReady means we got nil config.
- ErrRoundNotReady = errors.New("round is not ready")
+ // ErrNodeSetNotReady means we got nil empty node set.
+ ErrNodeSetNotReady = errors.New("node set is not ready")
+ // ErrCRSNotReady means we got empty CRS.
+ ErrCRSNotReady = errors.New("crs is not ready")
+ // ErrConfigurationNotReady means we go nil configuration.
+ ErrConfigurationNotReady = errors.New("configuration is not ready")
// ErrInvalidChainID means the chain ID is unexpected.
ErrInvalidChainID = errors.New("invalid chain id")
)
@@ -172,16 +176,15 @@ func (cache *NodeSetCache) update(
cache.lock.Lock()
defer cache.lock.Unlock()
- // Get the requested round.
+ // Get information for the requested round.
keySet := cache.nsIntf.NodeSet(round)
if keySet == nil {
- // That round is not ready yet.
- err = ErrRoundNotReady
+ err = ErrNodeSetNotReady
return
}
crs := cache.nsIntf.CRS(round)
if (crs == common.Hash{}) {
- err = ErrRoundNotReady
+ err = ErrCRSNotReady
return
}
// Cache new round.
@@ -199,6 +202,10 @@ func (cache *NodeSetCache) update(
}
}
cfg := cache.nsIntf.Configuration(round)
+ if cfg == nil {
+ err = ErrConfigurationNotReady
+ return
+ }
nIDs = &sets{
nodeSet: nodeSet,
notarySet: make([]map[types.NodeID]struct{}, cfg.NumChains),