Skip to content

Commit 144c385

Browse files
committed
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.
1 parent 85c78d5 commit 144c385

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,14 +1185,15 @@ PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CS
11851185
recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
11861186

11871187
// Blocks don't typically have more than 4000 transactions, so this should
1188-
// be at least six blocks (~1 hr) worth of transactions that we can store.
1188+
// be at least six blocks (~1 hr) worth of transactions that we can store,
1189+
// inserting both a txid and wtxid for every observed transaction.
11891190
// If the number of transactions appearing in a block goes up, or if we are
11901191
// seeing getdata requests more than an hour after initial announcement, we
11911192
// can increase this number.
11921193
// The false positive rate of 1/1M should come out to less than 1
11931194
// transaction per day that would be inadvertently ignored (which is the
11941195
// same probability that we have in the reject filter).
1195-
g_recent_confirmed_transactions.reset(new CRollingBloomFilter(24000, 0.000001));
1196+
g_recent_confirmed_transactions.reset(new CRollingBloomFilter(48000, 0.000001));
11961197

11971198
const Consensus::Params& consensusParams = Params().GetConsensus();
11981199
// 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
12481249
LOCK(g_cs_recent_confirmed_transactions);
12491250
for (const auto& ptx : pblock->vtx) {
12501251
g_recent_confirmed_transactions->insert(ptx->GetHash());
1252+
if (ptx->GetHash() != ptx->GetWitnessHash()) {
1253+
g_recent_confirmed_transactions->insert(ptx->GetWitnessHash());
1254+
}
12511255
}
12521256
}
12531257
}

0 commit comments

Comments
 (0)