MCPcopy Create free account
hub / github.com/ElementsProject/elements / CBlockHeaderAndShortTxIDs

Method CBlockHeaderAndShortTxIDs

src/blockencodings.cpp:19–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include <unordered_map>
18
19CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool fUseWTXID) :
20 nonce(GetRand(std::numeric_limits<uint64_t>::max())),
21 shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block) {
22 FillShortTxIDSelector();
23 //TODO: Use our mempool prior to block acceptance to predictively fill more than just the coinbase
24 prefilledtxn[0] = {0, block.vtx[0]};
25 for (size_t i = 1; i < block.vtx.size(); i++) {
26 const CTransaction& tx = *block.vtx[i];
27 shorttxids[i - 1] = GetShortID(fUseWTXID ? tx.GetWitnessHash() : tx.GetHash());
28 }
29}
30
31void CBlockHeaderAndShortTxIDs::FillShortTxIDSelector() const {
32 CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);

Callers

nothing calls this directly

Calls 3

GetRandFunction · 0.85
sizeMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected