19#include <unordered_map>
23 shorttxids(block.vtx.size() - 1),
30 for (
size_t i = 1; i < block.
vtx.size(); i++) {
49 static_assert(
SHORTTXIDS_LENGTH == 6,
"shorttxids calculation assumes 6-byte shorttxids");
95 const size_t tx_size{tx->ComputeTotalSize()};
108 std::unordered_map<uint64_t, uint16_t> shorttxids(
cmpctblock.shorttxids.size());
110 for (
size_t i = 0; i <
cmpctblock.shorttxids.size(); i++) {
124 if (shorttxids.bucket_size(shorttxids.bucket(
cmpctblock.shorttxids[i])) > 12)
127 if (shorttxids.size() !=
cmpctblock.shorttxids.size())
149 std::unordered_map<uint64_t, uint16_t>::iterator
idit = shorttxids.find(
shortid);
150 if (
idit != shorttxids.end()) {
172 for (
size_t i = 0; i <
extra_txn.size(); i++) {
174 std::unordered_map<uint64_t, uint16_t>::iterator
idit = shorttxids.find(
shortid);
175 if (
idit != shorttxids.end()) {
214 case TxSource::MEMPOOL:
219 case TxSource::EXTRA:
281 "Successfully reconstructed block %s with %u txn prefilled (%u bytes), "
282 "%u txn from mempool (%u bytes), "
283 "%u txn from extrapool (%u bytes), "
284 "and %u txn requested (%u bytes)",
291 "Block %s prefill redundancy statistics: "
292 "%u txn (%u bytes) of the prefill were redundant, "
293 "%u txn (%u bytes) were present in the mempool, "
294 "%u txn (%u bytes) were present in the extrapool.",
enum ReadStatus_t ReadStatus
#define Assert(val)
Identity function.
#define Assume(val)
Assume is the identity function.
CBlockHeaderAndShortTxIDs()=default
Dummy for deserialization.
void FillShortTxIDSelector() const
uint64_t GetShortID(const Wtxid &wtxid) const
std::vector< PrefilledTransaction > prefilledtxn
static constexpr int SHORTTXIDS_LENGTH
std::vector< uint64_t > shorttxids
std::optional< PresaltedSipHasher > m_hasher
std::vector< CTransactionRef > vtx
A hasher class for SHA-256.
CSHA256 & Write(const unsigned char *data, size_t len)
The basic transaction that is broadcasted on the network and contained in blocks.
const Wtxid & GetWitnessHash() const LIFETIMEBOUND
std::optional< txiter > GetIter(const Txid &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
Double ended buffer combining vector and stream-like interfaces.
size_t redundant_prefilled_extrapool_size
IsBlockMutatedFn m_check_block_mutated_mock
std::vector< CTransactionRef > txn_available
ReadStatus FillBlock(CBlock &block, const std::vector< CTransactionRef > &vtx_missing, bool segwit_active)
size_t redundant_prefilled_extrapool_count
std::function< bool(const CBlock &, bool)> IsBlockMutatedFn
size_t redundant_prefilled_mempool_size
size_t redundant_prefilled_mempool_count
bool IsTxAvailable(size_t index) const
ReadStatus InitData(const CBlockHeaderAndShortTxIDs &cmpctblock, const std::vector< std::pair< Wtxid, CTransactionRef > > &extra_txn)
constexpr size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT
constexpr unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
#define LogTrace(category,...)
#define LogDebug(category,...)
bool ShouldDebugLog(Category)
Return whether messages with specified category should be debug logged.
bool ShouldTraceLog(Category)
Return whether messages with specified category should be trace logged.
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
std::shared_ptr< const CTransaction > CTransactionRef
uint64_t GetSerializeSize(const T &t)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
bool IsBlockMutated(const CBlock &block, bool check_witness_root)
Check if a block has been mutated (with respect to its merkle root and witness commitments).