Changeset View
Changeset View
Standalone View
Standalone View
src/merkleblock.h
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | |||||
* If the CBlock has 0 txs, it will hit an assertion. | * If the CBlock has 0 txs, it will hit an assertion. | ||||
*/ | */ | ||||
class CMerkleBlock { | class CMerkleBlock { | ||||
public: | public: | ||||
/** Public only for unit testing */ | /** Public only for unit testing */ | ||||
CBlockHeader header; | CBlockHeader header; | ||||
CPartialMerkleTree txn; | CPartialMerkleTree txn; | ||||
/** Public only for unit testing and relay testing (not relayed) */ | /** | ||||
* Public only for unit testing and relay testing (not relayed). | |||||
* | |||||
* Used only when a bloom filter is specified to allow | |||||
* testing the transactions which matched the bloom filter. | |||||
*/ | |||||
std::vector<std::pair<size_t, uint256>> vMatchedTxn; | std::vector<std::pair<size_t, uint256>> vMatchedTxn; | ||||
/** | /** | ||||
* Create a Merkle proof according to a bloom filter. Note | * Create a Merkle proof according to a bloom filter. Note | ||||
* that this will call IsRelevantAndUpdate on the filter for each | * that this will call IsRelevantAndUpdate on the filter for each | ||||
* transaction, thus the filter will likely be modified. | * transaction, thus the filter will likely be modified. | ||||
*/ | */ | ||||
CMerkleBlock(const CBlock &block, CBloomFilter &filter); | CMerkleBlock(const CBlock &block, CBloomFilter &filter) | ||||
: CMerkleBlock(block, &filter, nullptr) {} | |||||
/** | /** | ||||
* Create a Merkle proof for a set of transactions. | * Create a Merkle proof for a set of transactions. | ||||
*/ | */ | ||||
CMerkleBlock(const CBlock &block, const std::set<TxId> &txids); | CMerkleBlock(const CBlock &block, const std::set<TxId> &txids) | ||||
: CMerkleBlock(block, nullptr, &txids) {} | |||||
CMerkleBlock() {} | CMerkleBlock() {} | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(header); | READWRITE(header); | ||||
READWRITE(txn); | READWRITE(txn); | ||||
} | } | ||||
private: | |||||
/** | |||||
* Combined constructor to consolidate code. At most one of filter | |||||
* or txids may be provided. | |||||
*/ | |||||
CMerkleBlock(const CBlock &block, CBloomFilter *filter, | |||||
const std::set<TxId> *txids); | |||||
}; | }; | ||||
#endif // BITCOIN_MERKLEBLOCK_H | #endif // BITCOIN_MERKLEBLOCK_H |