@@ -4781,10 +4781,16 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
4781
4781
pfrom->PushMessage (NetMsgType::BLOCK, block);
4782
4782
else if (inv.type == MSG_FILTERED_BLOCK)
4783
4783
{
4784
- LOCK (pfrom-> cs_filter ) ;
4785
- if (pfrom-> pfilter )
4784
+ bool send = false ;
4785
+ CMerkleBlock merkleBlock;
4786
4786
{
4787
- CMerkleBlock merkleBlock (block, *pfrom->pfilter );
4787
+ LOCK (pfrom->cs_filter );
4788
+ if (pfrom->pfilter ) {
4789
+ send = true ;
4790
+ merkleBlock = CMerkleBlock (block, *pfrom->pfilter );
4791
+ }
4792
+ }
4793
+ if (send) {
4788
4794
pfrom->PushMessage (NetMsgType::MERKLEBLOCK, merkleBlock);
4789
4795
// CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
4790
4796
// This avoids hurting performance by pointlessly requiring a round-trip
@@ -6052,8 +6058,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
6052
6058
CBloomFilter filter;
6053
6059
vRecv >> filter;
6054
6060
6055
- LOCK (pfrom->cs_filter );
6056
-
6057
6061
if (!filter.IsWithinSizeConstraints ())
6058
6062
{
6059
6063
// There is no excuse for sending a too-large filter
@@ -6062,11 +6066,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
6062
6066
}
6063
6067
else
6064
6068
{
6069
+ LOCK (pfrom->cs_filter );
6065
6070
delete pfrom->pfilter ;
6066
6071
pfrom->pfilter = new CBloomFilter (filter);
6067
6072
pfrom->pfilter ->UpdateEmptyFull ();
6073
+ pfrom->fRelayTxes = true ;
6068
6074
}
6069
- pfrom->fRelayTxes = true ;
6070
6075
}
6071
6076
6072
6077
@@ -6077,20 +6082,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
6077
6082
6078
6083
// Nodes must NEVER send a data item > 520 bytes (the max size for a script data object,
6079
6084
// and thus, the maximum size any matched object can have) in a filteradd message
6080
- if (vData.size () > MAX_SCRIPT_ELEMENT_SIZE)
6081
- {
6082
- LOCK (cs_main);
6083
- Misbehaving (pfrom->GetId (), 100 );
6085
+ bool bad = false ;
6086
+ if (vData.size () > MAX_SCRIPT_ELEMENT_SIZE) {
6087
+ bad = true ;
6084
6088
} else {
6085
6089
LOCK (pfrom->cs_filter );
6086
- if (pfrom->pfilter )
6090
+ if (pfrom->pfilter ) {
6087
6091
pfrom->pfilter ->insert (vData);
6088
- else
6089
- {
6090
- LOCK (cs_main);
6091
- Misbehaving (pfrom->GetId (), 100 );
6092
+ } else {
6093
+ bad = true ;
6092
6094
}
6093
6095
}
6096
+ if (bad) {
6097
+ LOCK (cs_main);
6098
+ Misbehaving (pfrom->GetId (), 100 );
6099
+ }
6094
6100
}
6095
6101
6096
6102
0 commit comments