@@ -2540,8 +2540,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2540
2540
return true ;
2541
2541
}
2542
2542
2543
- if (strCommand == NetMsgType::CMPCTBLOCK && ! fImporting && ! fReindex ) // Ignore blocks received while importing
2543
+ if (strCommand == NetMsgType::CMPCTBLOCK)
2544
2544
{
2545
+ // Ignore cmpctblock received while importing
2546
+ if (fImporting || fReindex ) {
2547
+ LogPrint (BCLog::NET, " Unexpected cmpctblock message received from peer %d\n " , pfrom->GetId ());
2548
+ return true ;
2549
+ }
2550
+
2545
2551
CBlockHeaderAndShortTxIDs cmpctblock;
2546
2552
vRecv >> cmpctblock;
2547
2553
@@ -2761,8 +2767,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2761
2767
return true ;
2762
2768
}
2763
2769
2764
- if (strCommand == NetMsgType::BLOCKTXN && ! fImporting && ! fReindex ) // Ignore blocks received while importing
2770
+ if (strCommand == NetMsgType::BLOCKTXN)
2765
2771
{
2772
+ // Ignore blocktxn received while importing
2773
+ if (fImporting || fReindex ) {
2774
+ LogPrint (BCLog::NET, " Unexpected blocktxn message received from peer %d\n " , pfrom->GetId ());
2775
+ return true ;
2776
+ }
2777
+
2766
2778
BlockTransactions resp;
2767
2779
vRecv >> resp;
2768
2780
@@ -2836,8 +2848,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2836
2848
return true ;
2837
2849
}
2838
2850
2839
- if (strCommand == NetMsgType::HEADERS && ! fImporting && ! fReindex ) // Ignore headers received while importing
2851
+ if (strCommand == NetMsgType::HEADERS)
2840
2852
{
2853
+ // Ignore headers received while importing
2854
+ if (fImporting || fReindex ) {
2855
+ LogPrint (BCLog::NET, " Unexpected headers message received from peer %d\n " , pfrom->GetId ());
2856
+ return true ;
2857
+ }
2858
+
2841
2859
std::vector<CBlockHeader> headers;
2842
2860
2843
2861
// Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks.
@@ -2861,8 +2879,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2861
2879
return ProcessHeadersMessage (pfrom, connman, headers, chainparams, should_punish);
2862
2880
}
2863
2881
2864
- if (strCommand == NetMsgType::BLOCK && ! fImporting && ! fReindex ) // Ignore blocks received while importing
2882
+ if (strCommand == NetMsgType::BLOCK)
2865
2883
{
2884
+ // Ignore block received while importing
2885
+ if (fImporting || fReindex ) {
2886
+ LogPrint (BCLog::NET, " Unexpected block message received from peer %d\n " , pfrom->GetId ());
2887
+ return true ;
2888
+ }
2889
+
2866
2890
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
2867
2891
vRecv >> *pblock;
2868
2892
0 commit comments