@@ -1857,17 +1857,6 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
1857
1857
}
1858
1858
1859
1859
void static InvalidBlockFound (CBlockIndex *pindex, const CValidationState &state) {
1860
- int nDoS = 0 ;
1861
- if (state.IsInvalid (nDoS)) {
1862
- std::map<uint256, NodeId>::iterator it = mapBlockSource.find (pindex->GetBlockHash ());
1863
- if (it != mapBlockSource.end () && State (it->second )) {
1864
- assert (state.GetRejectCode () < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
1865
- CBlockReject reject = {(unsigned char )state.GetRejectCode (), state.GetRejectReason ().substr (0 , MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash ()};
1866
- State (it->second )->rejects .push_back (reject);
1867
- if (nDoS > 0 )
1868
- Misbehaving (it->second , nDoS);
1869
- }
1870
- }
1871
1860
if (!state.CorruptionPossible ()) {
1872
1861
pindex->nStatus |= BLOCK_FAILED_VALID;
1873
1862
setDirtyBlockIndex.insert (pindex);
@@ -2814,7 +2803,6 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
2814
2803
InvalidBlockFound (pindexNew, state);
2815
2804
return error (" ConnectTip(): ConnectBlock %s failed" , pindexNew->GetBlockHash ().ToString ());
2816
2805
}
2817
- mapBlockSource.erase (pindexNew->GetBlockHash ());
2818
2806
nTime3 = GetTimeMicros (); nTimeConnectTotal += nTime3 - nTime2;
2819
2807
LogPrint (" bench" , " - Connect total: %.2fms [%.2fs]\n " , (nTime3 - nTime2) * 0.001 , nTimeConnectTotal * 0.000001 );
2820
2808
assert (view.Flush ());
@@ -4687,6 +4675,26 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CB
4687
4675
}
4688
4676
}
4689
4677
4678
+ void PeerLogicValidation::BlockChecked (const CBlock& block, const CValidationState& state) {
4679
+ LOCK (cs_main);
4680
+
4681
+ const uint256 hash (block.GetHash ());
4682
+ std::map<uint256, NodeId>::iterator it = mapBlockSource.find (hash);
4683
+
4684
+ int nDoS = 0 ;
4685
+ if (state.IsInvalid (nDoS)) {
4686
+ if (it != mapBlockSource.end () && State (it->second )) {
4687
+ assert (state.GetRejectCode () < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
4688
+ CBlockReject reject = {(unsigned char )state.GetRejectCode (), state.GetRejectReason ().substr (0 , MAX_REJECT_MESSAGE_LENGTH), hash};
4689
+ State (it->second )->rejects .push_back (reject);
4690
+ if (nDoS > 0 )
4691
+ Misbehaving (it->second , nDoS);
4692
+ }
4693
+ }
4694
+ if (it != mapBlockSource.end ())
4695
+ mapBlockSource.erase (it);
4696
+ }
4697
+
4690
4698
// ////////////////////////////////////////////////////////////////////////////
4691
4699
//
4692
4700
// Messages
0 commit comments