diff options
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go index 73b8abfd9..4f15a74ac 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go @@ -53,6 +53,8 @@ var ( "not enough of partial signatures") ErrRoundAlreadyPurged = fmt.Errorf( "cache of round already been purged") + ErrTSigNotReady = fmt.Errorf( + "tsig not ready") ) type dkgReceiver interface { @@ -400,6 +402,9 @@ func NewDKGGroupPublicKey( } } qualifyIDs := make(dkg.IDs, 0, len(mpks)-len(disqualifyIDs)) + if cap(qualifyIDs) < threshold { + return nil, ErrNotReachThreshold + } qualifyNodeIDs := make(map[types.NodeID]struct{}) mpkMap := make(map[dkg.ID]*typesDKG.MasterPublicKey, cap(qualifyIDs)) idMap := make(map[types.NodeID]dkg.ID) @@ -515,6 +520,13 @@ func (tc *TSigVerifierCache) Update(round uint64) (bool, error) { return true, nil } +// Delete the cache of given round. +func (tc *TSigVerifierCache) Delete(round uint64) { + tc.lock.Lock() + defer tc.lock.Unlock() + delete(tc.verifier, round) +} + // Get the TSigVerifier of round and returns if it exists. func (tc *TSigVerifierCache) Get(round uint64) (TSigVerifier, bool) { tc.lock.RLock() |