Skip to content

Commit 1f951c6

Browse files
committed
Allow filterclear messages for enabling TX relay only.
An example of where this might be useful is allowing a node to connect blocksonly during IBD but then becoming a full-node once caught up with the latest block. This might also even want to be the default behaviour since during IBD most TXs appear to be orphans, and are routinely dropped (for example when a node disconnects). Therefore, this can waste a lot of bandwidth. Additionally, another pull could be written to stop relaying of TXs to nodes that are clearly far behind the latest block and are running a node that doesn't store many orphan TXs, such as recent versions of Bitcoin Core.
1 parent 2a0836f commit 1f951c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4941,8 +4941,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49414941

49424942
if (!(pfrom->GetLocalServices() & NODE_BLOOM) &&
49434943
(strCommand == NetMsgType::FILTERLOAD ||
4944-
strCommand == NetMsgType::FILTERADD ||
4945-
strCommand == NetMsgType::FILTERCLEAR))
4944+
strCommand == NetMsgType::FILTERADD))
49464945
{
49474946
if (pfrom->nVersion >= NO_BLOOM_VERSION) {
49484947
LOCK(cs_main);
@@ -6128,8 +6127,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
61286127
else if (strCommand == NetMsgType::FILTERCLEAR)
61296128
{
61306129
LOCK(pfrom->cs_filter);
6131-
delete pfrom->pfilter;
6132-
pfrom->pfilter = new CBloomFilter();
6130+
if (pfrom->GetLocalServices() & NODE_BLOOM) {
6131+
delete pfrom->pfilter;
6132+
pfrom->pfilter = new CBloomFilter();
6133+
}
61336134
pfrom->fRelayTxes = true;
61346135
}
61356136

0 commit comments

Comments
 (0)