From 2681e011bd48ec107dedae9c7dcbc0810673298c Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Thu, 30 Aug 2018 10:45:06 +0800 Subject: core: Leader Selector. (#80) --- simulation/config/config.go | 8 ++++---- simulation/governance.go | 18 ++++++++++++++++-- simulation/kubernetes/config.toml.in | 4 ++++ 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'simulation') diff --git a/simulation/config/config.go b/simulation/config/config.go index 6ead62e..8a804a5 100644 --- a/simulation/config/config.go +++ b/simulation/config/config.go @@ -35,8 +35,8 @@ const ( // Agreement settings. type Agreement struct { - CRS string - K int + GenesisCRS string `toml:"genesis_crs"` + K int } // Consensus settings. @@ -91,8 +91,8 @@ func GenerateDefault(path string) error { Validator: Validator{ Consensus: Consensus{ Agreement: Agreement{ - CRS: "In DEXON we trust.", - K: 50, + GenesisCRS: "In DEXON we trust.", + K: 50, }, PhiRatio: float32(2) / 3, K: 1, diff --git a/simulation/governance.go b/simulation/governance.go index 7e3f6f2..7100d4c 100644 --- a/simulation/governance.go +++ b/simulation/governance.go @@ -34,6 +34,8 @@ type simGovernance struct { expectedNumValidators int k int phiRatio float32 + crs string + agreementK int } // newSimGovernance returns a new simGovernance instance. @@ -42,8 +44,10 @@ func newSimGovernance( return &simGovernance{ validatorSet: make(map[types.ValidatorID]decimal.Decimal), expectedNumValidators: numValidators, - k: consensusConfig.K, - phiRatio: consensusConfig.PhiRatio, + k: consensusConfig.K, + phiRatio: consensusConfig.PhiRatio, + crs: consensusConfig.Agreement.GenesisCRS, + agreementK: consensusConfig.Agreement.K, } } @@ -84,6 +88,16 @@ func (g *simGovernance) GetConfigurationChangeEvent( return nil } +// GetGenesisCRS returns CRS. +func (g *simGovernance) GetGenesisCRS() string { + return g.crs +} + +// GetAgreementK returns K for agreement. +func (g *simGovernance) GetAgreementK() int { + return g.agreementK +} + // addValidator add a new validator into the simulated governance contract. func (g *simGovernance) addValidator(vID types.ValidatorID) { g.lock.Lock() diff --git a/simulation/kubernetes/config.toml.in b/simulation/kubernetes/config.toml.in index 79e662a..3019920 100644 --- a/simulation/kubernetes/config.toml.in +++ b/simulation/kubernetes/config.toml.in @@ -10,6 +10,10 @@ max_block = 1000 phi_ratio = 6.66670024394989e-01 k = 1 +[validator.consensus.agreement] +genesis_crs = "In DEXON we trust." +k = 50 + [networking] type = "tcp" peer_server = "peer-server-svc.default.svc.cluster.local" -- cgit v1.2.3