Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

quorums_blockprocessor.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2020 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_BLOCKPROCESSOR_H
6 #define DASH_QUORUMS_BLOCKPROCESSOR_H
7 
9 #include <llmq/quorums_utils.h>
10 
11 #include <consensus/params.h>
12 #include <primitives/transaction.h>
13 #include <saltedhasher.h>
14 #include <sync.h>
15 
16 #include <map>
17 #include <unordered_map>
18 
19 class CNode;
20 class CConnman;
21 
22 namespace llmq
23 {
24 
26 {
27 private:
29 
30  // TODO cleanup
32  std::map<std::pair<Consensus::LLMQType, uint256>, uint256> minableCommitmentsByQuorum;
33  std::map<uint256, CFinalCommitment> minableCommitments;
34 
35  std::unordered_map<std::pair<Consensus::LLMQType, uint256>, bool, StaticSaltedHasher> hasMinedCommitmentCache;
36 
37 public:
38  explicit CQuorumBlockProcessor(CEvoDB& _evoDb) : evoDb(_evoDb) {}
39 
40  void UpgradeDB();
41 
42  void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
43 
44  bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
45  bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);
46 
47  void AddMinableCommitment(const CFinalCommitment& fqc);
48  bool HasMinableCommitment(const uint256& hash);
49  bool GetMinableCommitmentByHash(const uint256& commitmentHash, CFinalCommitment& ret);
50  bool GetMinableCommitment(Consensus::LLMQType llmqType, int nHeight, CFinalCommitment& ret);
51  bool GetMinableCommitmentTx(Consensus::LLMQType llmqType, int nHeight, CTransactionRef& ret);
52 
53  bool HasMinedCommitment(Consensus::LLMQType llmqType, const uint256& quorumHash);
54  bool GetMinedCommitment(Consensus::LLMQType llmqType, const uint256& quorumHash, CFinalCommitment& ret, uint256& retMinedBlockHash);
55 
56  std::vector<const CBlockIndex*> GetMinedCommitmentsUntilBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex, size_t maxCount);
57  std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> GetMinedAndActiveCommitmentsUntilBlock(const CBlockIndex* pindex);
58 
59 private:
60  bool GetCommitmentsFromBlock(const CBlock& block, const CBlockIndex* pindex, std::map<Consensus::LLMQType, CFinalCommitment>& ret, CValidationState& state);
61  bool ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, CValidationState& state);
62  bool IsMiningPhase(Consensus::LLMQType llmqType, int nHeight);
63  bool IsCommitmentRequired(Consensus::LLMQType llmqType, int nHeight);
64  uint256 GetQuorumBlockHash(Consensus::LLMQType llmqType, int nHeight);
65 };
66 
67 extern CQuorumBlockProcessor* quorumBlockProcessor;
68 
69 } // namespace llmq
70 
71 #endif//DASH_QUORUMS_BLOCKPROCESSOR_H
void AddMinableCommitment(const CFinalCommitment &fqc)
Definition: evodb.h:32
bool IsCommitmentRequired(Consensus::LLMQType llmqType, int nHeight)
Definition: block.h:72
CQuorumBlockProcessor * quorumBlockProcessor
bool GetMinableCommitmentTx(Consensus::LLMQType llmqType, int nHeight, CTransactionRef &ret)
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
bool ProcessBlock(const CBlock &block, const CBlockIndex *pindex, CValidationState &state)
bool HasMinedCommitment(Consensus::LLMQType llmqType, const uint256 &quorumHash)
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:345
LLMQType
Definition: params.h:48
std::map< Consensus::LLMQType, std::vector< const CBlockIndex * > > GetMinedAndActiveCommitmentsUntilBlock(const CBlockIndex *pindex)
void ProcessMessage(CNode *pfrom, const std::string &strCommand, CDataStream &vRecv, CConnman &connman)
Definition: net.h:136
bool GetMinableCommitmentByHash(const uint256 &commitmentHash, CFinalCommitment &ret)
bool HasMinableCommitment(const uint256 &hash)
Capture information about block/transaction validation.
Definition: validation.h:22
bool GetMinedCommitment(Consensus::LLMQType llmqType, const uint256 &quorumHash, CFinalCommitment &ret, uint256 &retMinedBlockHash)
256-bit opaque blob.
Definition: uint256.h:123
bool IsMiningPhase(Consensus::LLMQType llmqType, int nHeight)
bool GetCommitmentsFromBlock(const CBlock &block, const CBlockIndex *pindex, std::map< Consensus::LLMQType, CFinalCommitment > &ret, CValidationState &state)
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
bool UndoBlock(const CBlock &block, const CBlockIndex *pindex)
std::map< std::pair< Consensus::LLMQType, uint256 >, uint256 > minableCommitmentsByQuorum
std::unordered_map< std::pair< Consensus::LLMQType, uint256 >, bool, StaticSaltedHasher > hasMinedCommitmentCache
bool GetMinableCommitment(Consensus::LLMQType llmqType, int nHeight, CFinalCommitment &ret)
Information about a peer.
Definition: net.h:800
std::vector< const CBlockIndex * > GetMinedCommitmentsUntilBlock(Consensus::LLMQType llmqType, const CBlockIndex *pindex, size_t maxCount)
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the re...
Definition: sync.h:94
std::map< uint256, CFinalCommitment > minableCommitments
uint256 GetQuorumBlockHash(Consensus::LLMQType llmqType, int nHeight)
bool ProcessCommitment(int nHeight, const uint256 &blockHash, const CFinalCommitment &qc, CValidationState &state)
Released under the MIT license