aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-02 11:45:34 +0800
committerGitHub <noreply@github.com>2018-10-02 11:45:34 +0800
commit658662d42d30c58e4f3951f5c1e99688de295397 (patch)
tree41bb0f9129403eb1905172dc8409eac6761d5fea /simulation
parent9c33b9dc8aa59d414a6697f1e2d036e5581860ee (diff)
downloaddexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.tar
dexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.tar.gz
dexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.tar.bz2
dexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.tar.lz
dexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.tar.xz
dexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.tar.zst
dexon-consensus-658662d42d30c58e4f3951f5c1e99688de295397.zip
core: run DKG and CRS at background. (#155)
Diffstat (limited to 'simulation')
-rw-r--r--simulation/governance.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/simulation/governance.go b/simulation/governance.go
index 9e7cbaf..21bf35a 100644
--- a/simulation/governance.go
+++ b/simulation/governance.go
@@ -22,6 +22,7 @@ import (
"sync"
"time"
+ "github.com/dexon-foundation/dexon-consensus-core/common"
"github.com/dexon-foundation/dexon-consensus-core/core/crypto"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
"github.com/dexon-foundation/dexon-consensus-core/simulation/config"
@@ -37,7 +38,7 @@ type simGovernance struct {
k int
phiRatio float32
chainNum uint32
- crs map[uint64][]byte
+ crs map[uint64]common.Hash
tsig map[uint64]crypto.Signature
dkgComplaint map[uint64][]*types.DKGComplaint
dkgMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
@@ -51,6 +52,7 @@ type simGovernance struct {
func newSimGovernance(
id types.NodeID,
numNodes int, consensusConfig config.Consensus) *simGovernance {
+ hashCRS := crypto.Keccak256Hash([]byte(consensusConfig.GenesisCRS))
return &simGovernance{
id: id,
nodeSet: make(map[types.NodeID]crypto.PublicKey),
@@ -58,8 +60,8 @@ func newSimGovernance(
k: consensusConfig.K,
phiRatio: consensusConfig.PhiRatio,
chainNum: consensusConfig.ChainNum,
- crs: map[uint64][]byte{
- 0: []byte(consensusConfig.GenesisCRS)},
+ crs: map[uint64]common.Hash{
+ 0: hashCRS},
tsig: make(map[uint64]crypto.Signature),
dkgComplaint: make(map[uint64][]*types.DKGComplaint),
dkgMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
@@ -101,17 +103,18 @@ func (g *simGovernance) GetConfiguration(round uint64) *types.Config {
NumDKGSet: len(g.nodeSet),
MinBlockInterval: g.lambdaBA * 3,
MaxBlockInterval: g.lambdaBA * 8,
+ RoundInterval: g.roundInterval,
}
}
// GetCRS returns the CRS for a given round.
-func (g *simGovernance) GetCRS(round uint64) []byte {
+func (g *simGovernance) GetCRS(round uint64) common.Hash {
return g.crs[round]
}
// ProposeCRS proposes a CRS of round.
func (g *simGovernance) ProposeCRS(round uint64, crs []byte) {
- g.crs[round] = crs
+ g.crs[round] = crypto.Keccak256Hash(crs)
}
// addNode add a new node into the simulated governance contract.