diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-09-28 13:06:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-28 13:06:16 +0800 |
commit | 9ad4ae71b5a49ddc77687cc368c31416a0ee0688 (patch) | |
tree | ca29f72aa63b6610f0a8ec1aef2e842677e9ac6f /core | |
parent | 5fc0efa940c7663a33d0fc501807a2627d2cb573 (diff) | |
download | tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.gz tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.bz2 tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.lz tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.xz tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.tar.zst tangerine-consensus-9ad4ae71b5a49ddc77687cc368c31416a0ee0688.zip |
core: Add sizes of various nodeSets (#148)
Diffstat (limited to 'core')
-rw-r--r-- | core/test/governance.go | 24 | ||||
-rw-r--r-- | core/types/config.go | 33 |
2 files changed, 51 insertions, 6 deletions
diff --git a/core/test/governance.go b/core/test/governance.go index c666ffc..69d8bdd 100644 --- a/core/test/governance.go +++ b/core/test/governance.go @@ -41,6 +41,9 @@ type Governance struct { tsig map[uint64]crypto.Signature DKGComplaint map[uint64][]*types.DKGComplaint DKGMasterPublicKey map[uint64][]*types.DKGMasterPublicKey + RoundInterval time.Duration + MinBlockInterval time.Duration + MaxBlockInterval time.Duration lock sync.RWMutex } @@ -54,6 +57,9 @@ func NewGovernance(nodeCount int, lambda time.Duration) ( tsig: make(map[uint64]crypto.Signature), DKGComplaint: make(map[uint64][]*types.DKGComplaint), DKGMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey), + RoundInterval: 365 * 86400 * time.Second, + MinBlockInterval: lambda * 3, + MaxBlockInterval: lambda * 8, } for i := 0; i < nodeCount; i++ { prv, err := ecdsa.NewPrivateKey() @@ -79,12 +85,18 @@ func (g *Governance) GetNodeSet(_ uint64) ( // GetConfiguration returns the configuration at a given block height. func (g *Governance) GetConfiguration(_ uint64) *types.Config { return &types.Config{ - NumShards: 1, - NumChains: uint32(len(g.privateKeys)), - LambdaBA: g.lambdaBA, - LambdaDKG: g.lambdaDKG, - K: 0, - PhiRatio: 0.667, + NumShards: 1, + NumChains: uint32(len(g.privateKeys)), + LambdaBA: g.lambdaBA, + LambdaDKG: g.lambdaDKG, + K: 0, + PhiRatio: 0.667, + NumNotarySet: len(g.privateKeys), + NumWitnessSet: len(g.privateKeys), + NumDKGSet: len(g.privateKeys), + RoundInterval: g.RoundInterval, + MinBlockInterval: g.MinBlockInterval, + MaxBlockInterval: g.MaxBlockInterval, } } diff --git a/core/types/config.go b/core/types/config.go index 9434d62..0b85363 100644 --- a/core/types/config.go +++ b/core/types/config.go @@ -36,6 +36,16 @@ type Config struct { // Total ordering related. K int PhiRatio float32 + + // NodeSet related. + NumNotarySet int + NumWitnessSet int + NumDKGSet int + + // Time related. + RoundInterval time.Duration + MinBlockInterval time.Duration + MaxBlockInterval time.Duration } // Bytes returns []byte representation of Config. @@ -57,6 +67,23 @@ func (c *Config) Bytes() []byte { binaryPhiRatio := make([]byte, 4) binary.LittleEndian.PutUint32(binaryPhiRatio, math.Float32bits(c.PhiRatio)) + binaryNumNotarySet := make([]byte, 4) + binary.LittleEndian.PutUint32(binaryNumNotarySet, uint32(c.NumNotarySet)) + binaryNumWitnessSet := make([]byte, 4) + binary.LittleEndian.PutUint32(binaryNumWitnessSet, uint32(c.NumWitnessSet)) + binaryNumDKGSet := make([]byte, 4) + binary.LittleEndian.PutUint32(binaryNumDKGSet, uint32(c.NumDKGSet)) + + binaryRoundInterval := make([]byte, 8) + binary.LittleEndian.PutUint64(binaryRoundInterval, + uint64(c.RoundInterval.Nanoseconds())) + binaryMinBlockInterval := make([]byte, 8) + binary.LittleEndian.PutUint64(binaryMinBlockInterval, + uint64(c.MinBlockInterval.Nanoseconds())) + binaryMaxBlockInterval := make([]byte, 8) + binary.LittleEndian.PutUint64(binaryMaxBlockInterval, + uint64(c.MaxBlockInterval.Nanoseconds())) + enc := make([]byte, 0, 40) enc = append(enc, binaryNumShards...) enc = append(enc, binaryNumChains...) @@ -64,5 +91,11 @@ func (c *Config) Bytes() []byte { enc = append(enc, binaryLambdaDKG...) enc = append(enc, binaryK...) enc = append(enc, binaryPhiRatio...) + enc = append(enc, binaryNumNotarySet...) + enc = append(enc, binaryNumWitnessSet...) + enc = append(enc, binaryNumDKGSet...) + enc = append(enc, binaryRoundInterval...) + enc = append(enc, binaryMinBlockInterval...) + enc = append(enc, binaryMaxBlockInterval...) return enc } |