aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/governance.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-08 18:02:19 +0800
committerGitHub <noreply@github.com>2018-10-08 18:02:19 +0800
commit54b3726dc9183cbf2b517f71413a2559040ae5e0 (patch)
tree8ab2e3e360dac54d1b06c9dd93471b2555edf9be /core/test/governance.go
parente90d1ceaf78afeb624665c6d37a808ea7bbb294c (diff)
downloaddexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.tar
dexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.tar.gz
dexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.tar.bz2
dexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.tar.lz
dexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.tar.xz
dexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.tar.zst
dexon-consensus-54b3726dc9183cbf2b517f71413a2559040ae5e0.zip
core: Remove round from gov.ProposeCRS (#183)
Diffstat (limited to 'core/test/governance.go')
-rw-r--r--core/test/governance.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/test/governance.go b/core/test/governance.go
index 31fe5f4..f013534 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -40,7 +40,7 @@ type Governance struct {
lambdaBA time.Duration
lambdaDKG time.Duration
privateKeys map[types.NodeID]crypto.PrivateKey
- crs map[uint64]common.Hash
+ crs []common.Hash
tsig map[uint64]crypto.Signature
DKGComplaint map[uint64][]*types.DKGComplaint
DKGMasterPublicKey map[uint64][]*types.DKGMasterPublicKey
@@ -58,7 +58,7 @@ func NewGovernance(nodeCount int, lambda time.Duration) (
lambdaBA: lambda,
lambdaDKG: lambda * 10,
privateKeys: make(map[types.NodeID]crypto.PrivateKey),
- crs: map[uint64]common.Hash{0: hashCRS},
+ crs: []common.Hash{hashCRS},
tsig: make(map[uint64]crypto.Signature),
DKGComplaint: make(map[uint64][]*types.DKGComplaint),
DKGMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey),
@@ -107,14 +107,21 @@ func (g *Governance) Configuration(_ uint64) *types.Config {
func (g *Governance) CRS(round uint64) common.Hash {
g.lock.RLock()
defer g.lock.RUnlock()
+ if round >= uint64(len(g.crs)) {
+ return common.Hash{}
+ }
return g.crs[round]
}
// ProposeCRS propose a CRS.
-func (g *Governance) ProposeCRS(round uint64, signedCRS []byte) {
+func (g *Governance) ProposeCRS(signedCRS []byte) {
g.lock.Lock()
defer g.lock.Unlock()
- g.crs[round] = crypto.Keccak256Hash(signedCRS)
+ crs := crypto.Keccak256Hash(signedCRS)
+ if g.crs[len(g.crs)-1].Equal(crs) {
+ return
+ }
+ g.crs = append(g.crs, crs)
}
// PrivateKeys return the private key for that node, this function