@@ -6019,22 +6019,27 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
6019
6019
return true ;
6020
6020
}
6021
6021
6022
- BOOST_FOREACH ( const CBlockHeader& header, headers) {
6023
- CValidationState state;
6024
- if (pindexLast != NULL && header.hashPrevBlock != pindexLast-> GetBlockHash () ) {
6022
+ uint256 hashLastBlock;
6023
+ for ( const CBlockHeader& header : headers) {
6024
+ if (!hashLastBlock. IsNull () && header.hashPrevBlock != hashLastBlock ) {
6025
6025
Misbehaving (pfrom->GetId (), 20 );
6026
6026
return error (" non-continuous headers sequence" );
6027
6027
}
6028
- if (!AcceptBlockHeader (header, state, chainparams, &pindexLast)) {
6029
- int nDoS;
6030
- if (state.IsInvalid (nDoS)) {
6031
- if (nDoS > 0 )
6032
- Misbehaving (pfrom->GetId (), nDoS);
6033
- return error (" invalid header received" );
6028
+ hashLastBlock = header.GetHash ();
6029
+ }
6030
+ }
6031
+
6032
+ CValidationState state;
6033
+ if (!ProcessNewBlockHeaders (headers, state, chainparams, &pindexLast)) {
6034
+ int nDoS;
6035
+ if (state.IsInvalid (nDoS)) {
6036
+ if (nDoS > 0 ) {
6037
+ LOCK (cs_main);
6038
+ Misbehaving (pfrom->GetId (), nDoS);
6034
6039
}
6040
+ return error (" invalid header received" );
6035
6041
}
6036
6042
}
6037
- }
6038
6043
6039
6044
{
6040
6045
LOCK (cs_main);
@@ -6110,8 +6115,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
6110
6115
}
6111
6116
}
6112
6117
}
6113
-
6114
- NotifyHeaderTip ();
6115
6118
}
6116
6119
6117
6120
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex ) // Ignore blocks received while importing
0 commit comments