From a79c10ff1f4717e7e26096f81a57df10b8c9a592 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Wed, 26 Sep 2018 09:55:08 +0800 Subject: core: run TSIG for first configuration block at startup (#135) --- simulation/governance.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'simulation/governance.go') diff --git a/simulation/governance.go b/simulation/governance.go index 643c181..133276c 100644 --- a/simulation/governance.go +++ b/simulation/governance.go @@ -23,6 +23,7 @@ import ( "time" "github.com/dexon-foundation/dexon-consensus-core/core/types" + "github.com/dexon-foundation/dexon-consensus-core/crypto" "github.com/dexon-foundation/dexon-consensus-core/simulation/config" ) @@ -37,6 +38,7 @@ type simGovernance struct { phiRatio float32 chainNum uint32 crs []byte + tsig map[uint64]crypto.Signature dkgComplaint map[uint64][]*types.DKGComplaint dkgMasterPublicKey map[uint64][]*types.DKGMasterPublicKey lambdaBA time.Duration @@ -56,6 +58,7 @@ func newSimGovernance( phiRatio: consensusConfig.PhiRatio, chainNum: consensusConfig.ChainNum, crs: []byte(consensusConfig.GenesisCRS), + tsig: make(map[uint64]crypto.Signature), dkgComplaint: make(map[uint64][]*types.DKGComplaint), dkgMasterPublicKey: make(map[uint64][]*types.DKGMasterPublicKey), lambdaBA: time.Duration(consensusConfig.LambdaBA) * time.Millisecond, @@ -108,6 +111,19 @@ func (g *simGovernance) addNode(nID types.NodeID) { g.notarySet[nID] = struct{}{} } +// ProposeThresholdSignature porposes a ThresholdSignature of round. +func (g *simGovernance) ProposeThresholdSignature( + round uint64, signature crypto.Signature) { + g.tsig[round] = signature +} + +// GetThresholdSignature gets a ThresholdSignature of round. +func (g *simGovernance) GetThresholdSignature(round uint64) ( + sig crypto.Signature, exist bool) { + sig, exist = g.tsig[round] + return +} + // AddDKGComplaint adds a DKGComplaint. func (g *simGovernance) AddDKGComplaint(complaint *types.DKGComplaint) { // TODO(jimmy-dexon): check if the input is valid. -- cgit v1.2.3