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