mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Add wtxids of confirmed transactions to bloom filter
This is in preparation for wtxid-based invs (we need to be able to tell whether we AlreadyHave() a transaction based on either txid or wtxid). This also double the size of the bloom filter, which is overkill, but still uses a manageable amount of memory.
This commit is contained in:
parent
85c78d54af
commit
144c385820
1 changed files with 6 additions and 2 deletions
|
@ -1185,14 +1185,15 @@ PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CS
|
|||
recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
|
||||
|
||||
// Blocks don't typically have more than 4000 transactions, so this should
|
||||
// be at least six blocks (~1 hr) worth of transactions that we can store.
|
||||
// be at least six blocks (~1 hr) worth of transactions that we can store,
|
||||
// inserting both a txid and wtxid for every observed transaction.
|
||||
// If the number of transactions appearing in a block goes up, or if we are
|
||||
// seeing getdata requests more than an hour after initial announcement, we
|
||||
// can increase this number.
|
||||
// The false positive rate of 1/1M should come out to less than 1
|
||||
// transaction per day that would be inadvertently ignored (which is the
|
||||
// same probability that we have in the reject filter).
|
||||
g_recent_confirmed_transactions.reset(new CRollingBloomFilter(24000, 0.000001));
|
||||
g_recent_confirmed_transactions.reset(new CRollingBloomFilter(48000, 0.000001));
|
||||
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
// Stale tip checking and peer eviction are on two different timers, but we
|
||||
|
@ -1248,6 +1249,9 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
|
|||
LOCK(g_cs_recent_confirmed_transactions);
|
||||
for (const auto& ptx : pblock->vtx) {
|
||||
g_recent_confirmed_transactions->insert(ptx->GetHash());
|
||||
if (ptx->GetHash() != ptx->GetWitnessHash()) {
|
||||
g_recent_confirmed_transactions->insert(ptx->GetWitnessHash());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue