mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 28ce05d06f into merged_master (Bitcoin PR #19260)
This commit is contained in:
commit
4649bdde61
2 changed files with 18 additions and 18 deletions
|
|
@ -2215,20 +2215,6 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
|||
}
|
||||
|
||||
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM) &&
|
||||
(msg_type == NetMsgType::FILTERLOAD ||
|
||||
msg_type == NetMsgType::FILTERADD))
|
||||
{
|
||||
if (pfrom.nVersion >= NO_BLOOM_VERSION) {
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 100);
|
||||
return false;
|
||||
} else {
|
||||
pfrom.fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg_type == NetMsgType::VERSION) {
|
||||
// Each connection can only send one version message
|
||||
if (pfrom.nVersion != 0)
|
||||
|
|
@ -3447,6 +3433,10 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
|||
}
|
||||
|
||||
if (msg_type == NetMsgType::FILTERLOAD) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
||||
pfrom.fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
CBloomFilter filter;
|
||||
vRecv >> filter;
|
||||
|
||||
|
|
@ -3466,6 +3456,10 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
|||
}
|
||||
|
||||
if (msg_type == NetMsgType::FILTERADD) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
||||
pfrom.fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
std::vector<unsigned char> vData;
|
||||
vRecv >> vData;
|
||||
|
||||
|
|
@ -3490,13 +3484,15 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
|||
}
|
||||
|
||||
if (msg_type == NetMsgType::FILTERCLEAR) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
||||
pfrom.fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
if (pfrom.m_tx_relay == nullptr) {
|
||||
return true;
|
||||
}
|
||||
LOCK(pfrom.m_tx_relay->cs_filter);
|
||||
if (pfrom.GetLocalServices() & NODE_BLOOM) {
|
||||
pfrom.m_tx_relay->pfilter = nullptr;
|
||||
}
|
||||
pfrom.m_tx_relay->pfilter = nullptr;
|
||||
pfrom.m_tx_relay->fRelayTxes = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ Test that, when bloom filters are not enabled, nodes are disconnected if:
|
|||
1. They send a p2p mempool message
|
||||
2. They send a p2p filterload message
|
||||
3. They send a p2p filteradd message
|
||||
4. They send a p2p filterclear message
|
||||
"""
|
||||
|
||||
from test_framework.messages import msg_mempool, msg_filteradd, msg_filterload
|
||||
from test_framework.messages import msg_mempool, msg_filteradd, msg_filterload, msg_filterclear
|
||||
from test_framework.mininode import P2PInterface
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal
|
||||
|
|
@ -39,5 +40,8 @@ class P2PNobloomfilterMessages(BitcoinTestFramework):
|
|||
self.log.info("Test that node is disconnected if it sends filteradd message")
|
||||
self.test_message_causes_disconnect(msg_filteradd(data=b'\xcc'))
|
||||
|
||||
self.log.info("Test that peer is disconnected if it sends a filterclear message")
|
||||
self.test_message_causes_disconnect(msg_filterclear())
|
||||
|
||||
if __name__ == '__main__':
|
||||
P2PNobloomfilterMessages().main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue