aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2020-01-29 10:57:08 -0500
committerJohn Newbery <john@johnnewbery.com>2020-09-24 13:24:10 +0100
commit73845211d16ad1558d84c966ae18e3507fa7dea6 (patch)
tree238a6c20f9dff5b33fe75dcc8cd841893ffd48b3 /src
parent606755b840b1560e4f92c9252fa4cab6eacabdd3 (diff)
downloadbitcoin-73845211d16ad1558d84c966ae18e3507fa7dea6.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/net_processing.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index c168531e3a..ea502ff2f7 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1117,14 +1117,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
@@ -1176,6 +1177,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());
+ }
}
}
}