| 17 | #include <unordered_map> |
| 18 | |
| 19 | CBlockHeaderAndShortTxIDs::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 | |
| 31 | void CBlockHeaderAndShortTxIDs::FillShortTxIDSelector() const { |
| 32 | CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); |