aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2020-01-29 10:57:08 -0500
committerSuhas Daftuar <sdaftuar@gmail.com>2020-07-18 19:00:02 -0400
commit144c38582042c3b9ec53bb97ba0644fc0114f8fb (patch)
tree6626e52258adda8c7f9607c04c28517661a0b4bf /src/net_processing.cpp
parent85c78d54af462996a0bca6cf97f91e1aa8778ae8 (diff)
downloadbitcoin-144c38582042c3b9ec53bb97ba0644fc0114f8fb.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/net_processing.cpp')
-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 d6fa777a43..efc90f85e4 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -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());
+ }
}
}
}