aboutsummaryrefslogtreecommitdiffstats
path: root/core/test
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-09-18 09:07:52 +0800
committerGitHub <noreply@github.com>2018-09-18 09:07:52 +0800
commit81cf96477127a2da8843d544802027c7061a9c06 (patch)
tree70c06aec5df92df1dd93b605cc7afdbd2b8b0347 /core/test
parent8a908e98279d7e80978cd412057eddd4a6bbf06c (diff)
downloadtangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.gz
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.bz2
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.lz
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.xz
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.zst
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.zip
core: remove ticker parameter from NewConsensus
- remove BlockProposingInterval, it's replaced by lambda. - remove ticker parameter of NewConsensus, ticker would be derived from governance. - leave a backdoor to hook the construction of ticker. - move 'Lambda' config from to consensus.
Diffstat (limited to 'core/test')
-rw-r--r--core/test/governance.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/core/test/governance.go b/core/test/governance.go
index 64ca39f..1658e46 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -19,6 +19,7 @@ package test
import (
"fmt"
+ "time"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
"github.com/dexon-foundation/dexon-consensus-core/crypto"
@@ -34,22 +35,22 @@ var (
// Governance is an implementation of Goverance for testing purpose.
type Governance struct {
- BlockProposingInterval int
- Validators map[types.ValidatorID]decimal.Decimal
- PrivateKeys map[types.ValidatorID]crypto.PrivateKey
- DKGComplaint map[uint64][]*types.DKGComplaint
- DKGMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
+ Lambda time.Duration
+ Validators map[types.ValidatorID]decimal.Decimal
+ PrivateKeys map[types.ValidatorID]crypto.PrivateKey
+ DKGComplaint map[uint64][]*types.DKGComplaint
+ DKGMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
}
// NewGovernance constructs a Governance instance.
-func NewGovernance(validatorCount, proposingInterval int) (
+func NewGovernance(validatorCount int, lambda time.Duration) (
g *Governance, err error) {
g = &Governance{
- BlockProposingInterval: proposingInterval,
- Validators: make(map[types.ValidatorID]decimal.Decimal),
- PrivateKeys: make(map[types.ValidatorID]crypto.PrivateKey),
- DKGComplaint: make(map[uint64][]*types.DKGComplaint),
- DKGMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
+ Lambda: lambda,
+ Validators: make(map[types.ValidatorID]decimal.Decimal),
+ PrivateKeys: make(map[types.ValidatorID]crypto.PrivateKey),
+ DKGComplaint: make(map[uint64][]*types.DKGComplaint),
+ DKGMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
}
for i := 0; i < validatorCount; i++ {
prv, err := eth.NewPrivateKey()
@@ -69,12 +70,6 @@ func (g *Governance) GetValidatorSet() map[types.ValidatorID]decimal.Decimal {
return g.Validators
}
-// GetBlockProposingInterval implements Governance interface to return maximum
-// allowed block proposing interval in millisecond.
-func (g *Governance) GetBlockProposingInterval() int {
- return g.BlockProposingInterval
-}
-
// GetTotalOrderingK returns K.
func (g *Governance) GetTotalOrderingK() int {
return 0
@@ -107,8 +102,13 @@ func (g *Governance) GetGenesisCRS() string {
return "🆕 DEXON"
}
+// GetLambda returns lambda for BA.
+func (g *Governance) GetLambda() time.Duration {
+ return g.Lambda
+}
+
// GetPrivateKey return the private key for that validator, this function
-// is a test utility and not a general core.Governance interface.
+// is a test utility and not a general Governance interface.
func (g *Governance) GetPrivateKey(
vID types.ValidatorID) (key crypto.PrivateKey, err error) {