Example #1
0
CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block) :
        nonce(GetRand(std::numeric_limits<uint64_t>::max())),
        shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block) {
    FillShortTxIDSelector();
    //TODO: Use our mempool prior to block acceptance to predictively fill more than just the coinbase
    prefilledtxn[0] = {0, block.vtx[0]};
    for (size_t i = 1; i < block.vtx.size(); i++) {
        const CTransaction& tx = block.vtx[i];
        shorttxids[i - 1] = GetShortID(tx.GetHash());
    }
}
CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block)
    : nonce(GetRand(std::numeric_limits<uint64_t>::max()))
    , shorttxids(block.vtx.size() - 1)
    , prefilledtxn(1)
    , header(block)
{
    FillShortTxIDSelector();

    prefilledtxn[0] = { 0, block.vtx[0] };
    for (size_t i = 1; i < block.vtx.size(); i++) {
        const CTransaction& tx = block.vtx[i];
        shorttxids[i - 1] = GetShortID(tx.GetHash());
    }
}
Example #3
0
void CompactTxFinder::initMapping(uint64_t idk0, uint64_t idk1) {

    std::vector<uint256> hashes;
    mempool.queryHashes(hashes);

    for (auto& t : hashes) {
        uint64_t shortID = GetShortID(idk0, idk1, t);

        if (mappedMempool.count(shortID)) {

            LogPrint("thin", "ShortID hash collision in mempool");

            // Erase, so the tx re-fetched from peer instead.
            mappedMempool.erase(shortID);
            continue;
        }
        mappedMempool[shortID] = t;
    }
}