@@ -5017,9 +5017,16 @@ void static ProcessGetData(CNode* pfrom)
50175017 pfrom->PushMessage (NetMsgType::BLOCK, block);
50185018 else // MSG_FILTERED_BLOCK)
50195019 {
5020- LOCK (pfrom->cs_filter );
5021- if (pfrom->pfilter ) {
5022- CMerkleBlock merkleBlock (block, *pfrom->pfilter );
5020+ bool send = false ;
5021+ CMerkleBlock merkleBlock;
5022+ {
5023+ LOCK (pfrom->cs_filter );
5024+ if (pfrom->pfilter ) {
5025+ send = true ;
5026+ merkleBlock = CMerkleBlock (block, *pfrom->pfilter );
5027+ }
5028+ }
5029+ if (send) {
50235030 pfrom->PushMessage (NetMsgType::MERKLEBLOCK, merkleBlock);
50245031 // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
50255032 // This avoids hurting performance by pointlessly requiring a round-trip
@@ -5940,8 +5947,8 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
59405947 delete pfrom->pfilter ;
59415948 pfrom->pfilter = new CBloomFilter (filter);
59425949 pfrom->pfilter ->UpdateEmptyFull ();
5950+ pfrom->fRelayTxes = true ;
59435951 }
5944- pfrom->fRelayTxes = true ;
59455952 }
59465953
59475954
@@ -5951,18 +5958,21 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
59515958
59525959 // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object,
59535960 // and thus, the maximum size any matched object can have) in a filteradd message
5961+ bool bad = false ;
59545962 if (vData.size () > MAX_SCRIPT_ELEMENT_SIZE) {
5955- LOCK (cs_main);
5956- Misbehaving (pfrom->GetId (), 100 );
5963+ bad = true ;
59575964 } else {
59585965 LOCK (pfrom->cs_filter );
5959- if (pfrom->pfilter )
5966+ if (pfrom->pfilter ) {
59605967 pfrom->pfilter ->insert (vData);
5961- else {
5962- LOCK (cs_main);
5963- Misbehaving (pfrom->GetId (), 100 );
5968+ } else {
5969+ bad = true ;
59645970 }
59655971 }
5972+ if (bad) {
5973+ LOCK (cs_main);
5974+ Misbehaving (pfrom->GetId (), 100 );
5975+ }
59665976 }
59675977
59685978
0 commit comments