Skip to content

Commit 1c9809f

Browse files
filters: add cross-reference comments to keep bloom and compact filter extraction in sync
Add maintenance notes in ExtractSpecialTxFilterElements and CBloomFilter::CheckSpecialTransactionMatchesAndUpdate to ensure future changes update both implementations together.
1 parent 7a33c14 commit 1c9809f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/common/bloom.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ bool CBloomFilter::CheckScript(const CScript &script) const
119119
// Filter is updated only if it has BLOOM_UPDATE_ALL flag to be able to have
120120
// simple SPV wallets that doesn't work with DIP2 transactions (multicoin
121121
// wallets, etc.)
122+
// NOTE(maintenance): Keep this implementation in sync with
123+
// ExtractSpecialTxFilterElements in src/evo/specialtx_filter.cpp.
124+
// Both routines must handle the same set of special-transaction fields.
125+
// If you modify one, update the other to prevent mismatches between
126+
// bloom filter relevance and compact filter element extraction.
122127
bool CBloomFilter::CheckSpecialTransactionMatchesAndUpdate(const CTransaction &tx)
123128
{
124129
if (!tx.HasExtraPayloadField()) {

src/evo/specialtx_filter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ static void AddHashElement(const T& hash,
4949
addElement(std::vector<unsigned char>(hash.begin(), hash.end()));
5050
}
5151

52+
// NOTE(maintenance): Keep this in sync with
53+
// CBloomFilter::CheckSpecialTransactionMatchesAndUpdate in
54+
// src/common/bloom.cpp. If you add or remove fields for a special
55+
// transaction type here, update the bloom filter routine accordingly
56+
// (and vice versa) to avoid compact-filter vs bloom-filter divergence.
5257
void ExtractSpecialTxFilterElements(const CTransaction& tx,
5358
const std::function<void(const std::vector<unsigned char>&)>& addElement)
5459
{

0 commit comments

Comments
 (0)