12 #include "validation.h"
19 static const std::string DB_VVEC =
"qdkg_V";
20 static const std::string DB_SKCONTRIB =
"qdkg_S";
25 for (
const auto& qt :
Params().GetConsensus().llmqs) {
27 std::forward_as_tuple(qt.first),
28 std::forward_as_tuple(qt.second,
blsWorker, *
this));
35 it.second.StartThread();
42 it.second.StopThread();
58 qt.second.UpdatedBlockTip(pindexNew);
81 auto& dkgType = p.second;
82 if (dkgType.pendingContributions.HasSeen(inv.
hash)
83 || dkgType.pendingComplaints.HasSeen(inv.
hash)
84 || dkgType.pendingJustifications.HasSeen(inv.
hash)
85 || dkgType.pendingPrematureCommitments.HasSeen(inv.
hash)) {
95 auto& dkgType = p.second;
96 LOCK2(dkgType.cs, dkgType.curSession->invCs);
100 auto it = dkgType.curSession->contributions.find(hash);
101 if (it != dkgType.curSession->contributions.end()) {
112 auto& dkgType = p.second;
113 LOCK2(dkgType.cs, dkgType.curSession->invCs);
117 auto it = dkgType.curSession->complaints.find(hash);
118 if (it != dkgType.curSession->complaints.end()) {
129 auto& dkgType = p.second;
130 LOCK2(dkgType.cs, dkgType.curSession->invCs);
134 auto it = dkgType.curSession->justifications.find(hash);
135 if (it != dkgType.curSession->justifications.end()) {
146 auto& dkgType = p.second;
147 LOCK2(dkgType.cs, dkgType.curSession->invCs);
151 auto it = dkgType.curSession->prematureCommitments.find(hash);
152 if (it != dkgType.curSession->prematureCommitments.end() && dkgType.curSession->validCommitments.count(hash)) {
174 memberIndexesRet.clear();
176 skContributionsRet.clear();
177 memberIndexesRet.reserve(members.size());
178 vvecsRet.reserve(members.size());
179 skContributionsRet.reserve(members.size());
180 for (
size_t i = 0; i < members.size(); i++) {
181 if (validMembers[i]) {
188 memberIndexesRet.emplace_back(i);
189 vvecsRet.emplace_back(vvec);
190 skContributionsRet.emplace_back(skContribution);
203 vvecRet = it->second.vvec;
204 skContributionRet = it->second.skContribution;
211 if (
llmqDb.
Read(std::make_tuple(DB_VVEC, (uint8_t)llmqType, quorumHash,
proTxHash), vvec)) {
212 vvecPtr = std::make_shared<BLSVerificationVector>(std::move(vvec));
214 llmqDb.
Read(std::make_tuple(DB_SKCONTRIB, (uint8_t)llmqType, quorumHash,
proTxHash), skContribution);
218 vvecRet = it->second.vvec;
219 skContributionRet = it->second.skContribution;
std::vector< CBLSPublicKey > BLSVerificationVector
std::shared_ptr< BLSVerificationVector > BLSVerificationVectorPtr
std::vector< CBLSSecretKey > BLSSecretKeyVector
const CChainParams & Params()
Return the currently selected parameters.
const_iterator begin() const
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
bool Read(const K &key, V &value) const
bool Write(const K &key, const V &value, bool fSync=false)
Information about a peer.
bool AlreadyHave(const CInv &inv) const
bool GetVerifiedContribution(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const uint256 &proTxHash, BLSVerificationVectorPtr &vvecRet, CBLSSecretKey &skContributionRet)
std::map< ContributionsCacheKey, ContributionsCacheEntry > contributionsCache
RecursiveMutex contributionsCacheCs
std::map< Consensus::LLMQType, CDKGSessionHandler > dkgSessionHandlers
static const int64_t MAX_CONTRIBUTION_CACHE_TIME
bool GetJustification(const uint256 &hash, CDKGJustification &ret) const
bool GetPrematureCommitment(const uint256 &hash, CDKGPrematureCommitment &ret) const
CDKGSessionManager(CDBWrapper &_evoDb, CBLSWorker &_blsWorker)
bool GetContribution(const uint256 &hash, CDKGContribution &ret) const
void WriteVerifiedSkContribution(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const uint256 &proTxHash, const CBLSSecretKey &skContribution)
void WriteVerifiedVvecContribution(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const uint256 &proTxHash, const BLSVerificationVectorPtr &vvec)
void UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload)
bool ProcessMessage(CNode *pfrom, const std::string &strCommand, CDataStream &vRecv)
bool GetVerifiedContributions(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const std::vector< bool > &validMembers, std::vector< uint16_t > &memberIndexesRet, std::vector< BLSVerificationVectorPtr > &vvecsRet, BLSSecretKeyVector &skContributionsRet)
bool GetComplaint(const uint256 &hash, CDKGComplaint &ret) const
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
@ QuorumPhase_Initialized
std::unique_ptr< CDKGSessionManager > quorumDKGSessionManager
RecursiveMutex cs_main
Global state.
int64_t GetTimeMillis()
Returns the system time (not mockable)