aboutsummaryrefslogtreecommitdiffstats
path: root/core/consensus-timestamp.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-03 17:48:56 +0800
committerGitHub <noreply@github.com>2018-10-03 17:48:56 +0800
commitf5f34f81f8f3149adb002c65a7cc0cfa1244f77d (patch)
treee7b9ce05f6943fcd8f2e4cb17edac9e5272529a0 /core/consensus-timestamp.go
parent3bab25bee98df72a25c273d6de1166facaa6a69e (diff)
downloaddexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.tar
dexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.tar.gz
dexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.tar.bz2
dexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.tar.lz
dexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.tar.xz
dexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.tar.zst
dexon-consensus-f5f34f81f8f3149adb002c65a7cc0cfa1244f77d.zip
core: publish round based config (#165)
Diffstat (limited to 'core/consensus-timestamp.go')
-rw-r--r--core/consensus-timestamp.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/core/consensus-timestamp.go b/core/consensus-timestamp.go
index c43ca82..9188c02 100644
--- a/core/consensus-timestamp.go
+++ b/core/consensus-timestamp.go
@@ -27,6 +27,10 @@ import (
// consensusTimestamp is for Concensus Timestamp Algorithm.
type consensusTimestamp struct {
chainTimestamps []time.Time
+
+ // This part keeps configs for each round.
+ numChainsForRounds []uint32
+ minRound uint64
}
var (
@@ -36,8 +40,23 @@ var (
)
// newConsensusTimestamp create timestamper object.
-func newConsensusTimestamp() *consensusTimestamp {
- return &consensusTimestamp{}
+func newConsensusTimestamp(round uint64, numChains uint32) *consensusTimestamp {
+ return &consensusTimestamp{
+ numChainsForRounds: []uint32{numChains},
+ minRound: round,
+ }
+}
+
+// appendConfig appends a configuration for upcoming round. When you append
+// a config for round R, next time you can only append the config for round R+1.
+func (ct *consensusTimestamp) appendConfig(
+ round uint64, config *types.Config) error {
+
+ if round != ct.minRound+uint64(len(ct.numChainsForRounds)) {
+ return ErrRoundNotIncreasing
+ }
+ ct.numChainsForRounds = append(ct.numChainsForRounds, config.NumChains)
+ return nil
}
// ProcessBlocks is the entry function.