aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go33
1 files changed, 5 insertions, 28 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go
index c9d31f8c4..eda09f06e 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/config.go
@@ -19,52 +19,38 @@ package types
import (
"encoding/binary"
- "math"
"time"
)
// Config stands for Current Configuration Parameters.
type Config struct {
- // Network related.
- NumChains uint32
-
// Lambda related.
LambdaBA time.Duration
LambdaDKG time.Duration
- // Total ordering related.
- K int
- PhiRatio float32
-
// Set related.
NotarySetSize uint32
DKGSetSize uint32
// Time related.
- RoundInterval time.Duration
+ RoundLength uint64
MinBlockInterval time.Duration
}
// Clone return a copied configuration.
func (c *Config) Clone() *Config {
return &Config{
- NumChains: c.NumChains,
LambdaBA: c.LambdaBA,
LambdaDKG: c.LambdaDKG,
- K: c.K,
- PhiRatio: c.PhiRatio,
NotarySetSize: c.NotarySetSize,
DKGSetSize: c.DKGSetSize,
- RoundInterval: c.RoundInterval,
+ RoundLength: c.RoundLength,
MinBlockInterval: c.MinBlockInterval,
}
}
// Bytes returns []byte representation of Config.
func (c *Config) Bytes() []byte {
- binaryNumChains := make([]byte, 4)
- binary.LittleEndian.PutUint32(binaryNumChains, c.NumChains)
-
binaryLambdaBA := make([]byte, 8)
binary.LittleEndian.PutUint64(
binaryLambdaBA, uint64(c.LambdaBA.Nanoseconds()))
@@ -72,32 +58,23 @@ func (c *Config) Bytes() []byte {
binary.LittleEndian.PutUint64(
binaryLambdaDKG, uint64(c.LambdaDKG.Nanoseconds()))
- binaryK := make([]byte, 4)
- binary.LittleEndian.PutUint32(binaryK, uint32(c.K))
- binaryPhiRatio := make([]byte, 4)
- binary.LittleEndian.PutUint32(binaryPhiRatio, math.Float32bits(c.PhiRatio))
-
binaryNotarySetSize := make([]byte, 4)
binary.LittleEndian.PutUint32(binaryNotarySetSize, c.NotarySetSize)
binaryDKGSetSize := make([]byte, 4)
binary.LittleEndian.PutUint32(binaryDKGSetSize, c.DKGSetSize)
- binaryRoundInterval := make([]byte, 8)
- binary.LittleEndian.PutUint64(binaryRoundInterval,
- uint64(c.RoundInterval.Nanoseconds()))
+ binaryRoundLength := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryRoundLength, c.RoundLength)
binaryMinBlockInterval := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryMinBlockInterval,
uint64(c.MinBlockInterval.Nanoseconds()))
enc := make([]byte, 0, 40)
- enc = append(enc, binaryNumChains...)
enc = append(enc, binaryLambdaBA...)
enc = append(enc, binaryLambdaDKG...)
- enc = append(enc, binaryK...)
- enc = append(enc, binaryPhiRatio...)
enc = append(enc, binaryNotarySetSize...)
enc = append(enc, binaryDKGSetSize...)
- enc = append(enc, binaryRoundInterval...)
+ enc = append(enc, binaryRoundLength...)
enc = append(enc, binaryMinBlockInterval...)
return enc
}