diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-30 10:45:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 10:45:06 +0800 |
commit | 2681e011bd48ec107dedae9c7dcbc0810673298c (patch) | |
tree | 11dbe2b7ff285d3fa57d983e1103ccb61bfe122c /simulation | |
parent | ca3b30a62ff85090c1a721602e8b202e6ae9a2bd (diff) | |
download | dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.tar dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.tar.gz dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.tar.bz2 dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.tar.lz dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.tar.xz dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.tar.zst dexon-consensus-2681e011bd48ec107dedae9c7dcbc0810673298c.zip |
core: Leader Selector. (#80)
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/config/config.go | 8 | ||||
-rw-r--r-- | simulation/governance.go | 18 | ||||
-rw-r--r-- | simulation/kubernetes/config.toml.in | 4 |
3 files changed, 24 insertions, 6 deletions
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" |