diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-31 14:02:39 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:17 +0800 |
commit | 79b3816f9ac27e151d2b9d6a76790fac8787e978 (patch) | |
tree | 4ed14fa46d27ce54e5550a1cd1af81dde0bdffd6 /vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go | |
parent | 0cbf04193ea79661f191cdaaca8f179d8b5db999 (diff) | |
download | go-tangerine-79b3816f9ac27e151d2b9d6a76790fac8787e978.tar.gz go-tangerine-79b3816f9ac27e151d2b9d6a76790fac8787e978.tar.zst go-tangerine-79b3816f9ac27e151d2b9d6a76790fac8787e978.zip |
vendor: sync consensus core and fix conflict
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go index f3a596e2b..e3fdbccf3 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/dkg-tsig-protocol.go @@ -106,9 +106,25 @@ type TSigVerifier interface { VerifySignature(hash common.Hash, sig crypto.Signature) bool } +// TSigVerifierCacheInterface specifies interface used by TSigVerifierCache. +type TSigVerifierCacheInterface interface { + // Configuration returns the configuration at a given round. + // Return the genesis configuration if round == 0. + Configuration(round uint64) *types.Config + + // DKGComplaints gets all the DKGComplaints of round. + DKGComplaints(round uint64) []*typesDKG.Complaint + + // DKGMasterPublicKeys gets all the DKGMasterPublicKey of round. + DKGMasterPublicKeys(round uint64) []*typesDKG.MasterPublicKey + + // IsDKGFinal checks if DKG is final. + IsDKGFinal(round uint64) bool +} + // TSigVerifierCache is the cache for TSigVerifier. type TSigVerifierCache struct { - gov Governance + intf TSigVerifierCacheInterface verifier map[uint64]TSigVerifier minRound uint64 cacheSize int @@ -431,9 +447,10 @@ func (gpk *DKGGroupPublicKey) VerifySignature( } // NewTSigVerifierCache creats a DKGGroupPublicKey instance. -func NewTSigVerifierCache(gov Governance, cacheSize int) *TSigVerifierCache { +func NewTSigVerifierCache( + intf TSigVerifierCacheInterface, cacheSize int) *TSigVerifierCache { return &TSigVerifierCache{ - gov: gov, + intf: intf, verifier: make(map[uint64]TSigVerifier), cacheSize: cacheSize, } @@ -463,13 +480,13 @@ func (tc *TSigVerifierCache) Update(round uint64) (bool, error) { if _, exist := tc.verifier[round]; exist { return true, nil } - if !tc.gov.IsDKGFinal(round) { + if !tc.intf.IsDKGFinal(round) { return false, nil } gpk, err := NewDKGGroupPublicKey(round, - tc.gov.DKGMasterPublicKeys(round), - tc.gov.DKGComplaints(round), - int(tc.gov.Configuration(round).DKGSetSize/3)+1) + tc.intf.DKGMasterPublicKeys(round), + tc.intf.DKGComplaints(round), + int(tc.intf.Configuration(round).DKGSetSize/3)+1) if err != nil { return false, err } |