Skip to content

Commit 7384521

Browse files
sdaftuarjnewbery
authored andcommitted
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 606755b commit 7384521

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
@@ -1117,14 +1117,15 @@ PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CS
11171117
recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
11181118

11191119
// Blocks don't typically have more than 4000 transactions, so this should
1120-
// be at least six blocks (~1 hr) worth of transactions that we can store.
1120+
// be at least six blocks (~1 hr) worth of transactions that we can store,
1121+
// inserting both a txid and wtxid for every observed transaction.
11211122
// If the number of transactions appearing in a block goes up, or if we are
11221123
// seeing getdata requests more than an hour after initial announcement, we
11231124
// can increase this number.
11241125
// The false positive rate of 1/1M should come out to less than 1
11251126
// transaction per day that would be inadvertently ignored (which is the
11261127
// same probability that we have in the reject filter).
1127-
g_recent_confirmed_transactions.reset(new CRollingBloomFilter(24000, 0.000001));
1128+
g_recent_confirmed_transactions.reset(new CRollingBloomFilter(48000, 0.000001));
11281129

11291130
const Consensus::Params& consensusParams = Params().GetConsensus();
11301131
// Stale tip checking and peer eviction are on two different timers, but we
@@ -1176,6 +1177,9 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
11761177
LOCK(g_cs_recent_confirmed_transactions);
11771178
for (const auto& ptx : pblock->vtx) {
11781179
g_recent_confirmed_transactions->insert(ptx->GetHash());
1180+
if (ptx->GetHash() != ptx->GetWitnessHash()) {
1181+
g_recent_confirmed_transactions->insert(ptx->GetWitnessHash());
1182+
}
11791183
}
11801184
}
11811185
}

0 commit comments

Comments
 (0)