aboutsummaryrefslogtreecommitdiffstats
path: root/core/consensus-timestamp.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-12-27 11:00:13 +0800
committerGitHub <noreply@github.com>2018-12-27 11:00:13 +0800
commit3ef65533cf0624adf6b09b133ff50c88fdf1303f (patch)
tree7b143301dd436456699868101b0e6787e59d2139 /core/consensus-timestamp.go
parent2a8254195f56cc10252753f828458b6efe222558 (diff)
downloaddexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.tar
dexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.tar.gz
dexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.tar.bz2
dexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.tar.lz
dexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.tar.xz
dexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.tar.zst
dexon-consensus-3ef65533cf0624adf6b09b133ff50c88fdf1303f.zip
Fix: consensusTimestamp panic when numChains increased at round 1(#382)
Diffstat (limited to 'core/consensus-timestamp.go')
-rw-r--r--core/consensus-timestamp.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/consensus-timestamp.go b/core/consensus-timestamp.go
index a1ace97..d7ce8e2 100644
--- a/core/consensus-timestamp.go
+++ b/core/consensus-timestamp.go
@@ -80,6 +80,15 @@ func (ct *consensusTimestamp) appendConfig(
if round != uint64(len(ct.numChainsOfRounds))+ct.numChainsBase {
return ErrRoundNotIncreasing
}
+ // This segment is to handle the corner case for config checking logic in
+ // processBlock method.
+ if len(ct.numChainsOfRounds) == 1 {
+ if ct.numChainsOfRounds[0] > config.NumChains {
+ ct.resizeTimetamps(ct.numChainsOfRounds[0])
+ } else {
+ ct.resizeTimetamps(config.NumChains)
+ }
+ }
ct.numChainsOfRounds = append(ct.numChainsOfRounds, config.NumChains)
return nil
}