Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

quorums_dkgsessionmgr.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2019 The Dash Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef DASH_QUORUMS_DKGSESSIONMGR_H
6 #define DASH_QUORUMS_DKGSESSIONMGR_H
7 
9 
10 #include <validation.h>
11 
12 #include <ctpl.h>
13 
14 class UniValue;
15 
16 namespace llmq
17 {
18 
20 {
21  static const int64_t MAX_CONTRIBUTION_CACHE_TIME = 60 * 1000;
22 
23 private:
26 
27  std::map<Consensus::LLMQType, CDKGSessionHandler> dkgSessionHandlers;
28 
34  bool operator<(const ContributionsCacheKey& r) const
35  {
36  if (llmqType != r.llmqType) return llmqType < r.llmqType;
37  if (quorumHash != r.quorumHash) return quorumHash < r.quorumHash;
38  return proTxHash < r.proTxHash;
39  }
40  };
42  int64_t entryTime;
45  };
46  std::map<ContributionsCacheKey, ContributionsCacheEntry> contributionsCache;
47 
48 public:
49  CDKGSessionManager(CDBWrapper& _llmqDb, CBLSWorker& _blsWorker);
51 
52  void StartThreads();
53  void StopThreads();
54 
55  void UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload);
56 
57  void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
58  bool AlreadyHave(const CInv& inv) const;
59  bool GetContribution(const uint256& hash, CDKGContribution& ret) const;
60  bool GetComplaint(const uint256& hash, CDKGComplaint& ret) const;
61  bool GetJustification(const uint256& hash, CDKGJustification& ret) const;
62  bool GetPrematureCommitment(const uint256& hash, CDKGPrematureCommitment& ret) const;
63 
64  // Verified contributions are written while in the DKG
65  void WriteVerifiedVvecContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& proTxHash, const BLSVerificationVectorPtr& vvec);
66  void WriteVerifiedSkContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& proTxHash, const CBLSSecretKey& skContribution);
67  bool GetVerifiedContributions(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const std::vector<bool>& validMembers, std::vector<uint16_t>& memberIndexesRet, std::vector<BLSVerificationVectorPtr>& vvecsRet, BLSSecretKeyVector& skContributionsRet);
68  bool GetVerifiedContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& proTxHash, BLSVerificationVectorPtr& vvecRet, CBLSSecretKey& skContributionRet);
69 
70 private:
71  void CleanupCache();
72 };
73 
75 
76 } // namespace llmq
77 
78 #endif //DASH_QUORUMS_DKGSESSIONMGR_H
CCriticalSection contributionsCacheCs
std::map< Consensus::LLMQType, CDKGSessionHandler > dkgSessionHandlers
static const int64_t MAX_CONTRIBUTION_CACHE_TIME
void WriteVerifiedSkContribution(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const uint256 &proTxHash, const CBLSSecretKey &skContribution)
CDKGSessionManager * quorumDKGSessionManager
inv message data
Definition: protocol.h:429
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
bool operator<(const ContributionsCacheKey &r) const
bool GetVerifiedContribution(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const uint256 &proTxHash, BLSVerificationVectorPtr &vvecRet, CBLSSecretKey &skContributionRet)
std::vector< CBLSSecretKey > BLSSecretKeyVector
Definition: bls.h:467
bool GetVerifiedContributions(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const std::vector< bool > &validMembers, std::vector< uint16_t > &memberIndexesRet, std::vector< BLSVerificationVectorPtr > &vvecsRet, BLSSecretKeyVector &skContributionsRet)
LLMQType
Definition: params.h:48
std::shared_ptr< BLSVerificationVector > BLSVerificationVectorPtr
Definition: bls.h:471
void ProcessMessage(CNode *pfrom, const std::string &strCommand, CDataStream &vRecv, CConnman &connman)
bool GetJustification(const uint256 &hash, CDKGJustification &ret) const
bool GetContribution(const uint256 &hash, CDKGContribution &ret) const
Definition: net.h:136
256-bit opaque blob.
Definition: uint256.h:123
bool GetPrematureCommitment(const uint256 &hash, CDKGPrematureCommitment &ret) const
void WriteVerifiedVvecContribution(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum, const uint256 &proTxHash, const BLSVerificationVectorPtr &vvec)
void UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload)
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
CBLSSecretKey skContribution
BLSVerificationVectorPtr vvec
int64_t entryTime
CDKGSessionManager(CDBWrapper &_llmqDb, CBLSWorker &_blsWorker)
Information about a peer.
Definition: net.h:800
std::map< ContributionsCacheKey, ContributionsCacheEntry > contributionsCache
bool GetComplaint(const uint256 &hash, CDKGComplaint &ret) const
bool AlreadyHave(const CInv &inv) const
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the re...
Definition: sync.h:94
Released under the MIT license