MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / InvalidBlockFound

Function InvalidBlockFound

src/main.cpp:519–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void static InvalidBlockFound(CBlockIndex *pIndex, CBlock &block, const CValidationState &state) {
520 int32_t nDoS = 0;
521 if (state.IsInvalid(nDoS)) {
522 LOCK(cs_mapNodeState);
523 map<uint256, NodeId>::iterator it = mapBlockSource.find(pIndex->GetBlockHash());
524 if (it != mapBlockSource.end() && State(it->second)) {
525 CBlockReject reject = {state.GetRejectCode(), state.GetRejectReason(), pIndex->GetBlockHash()};
526 State(it->second)->rejects.push_back(reject);
527 if (nDoS > 0) {
528 LogPrint(BCLog::INFO, "Misebehaving: found invalid block, hash:%s, Misbehavior add %d\n", it->first.GetHex(),
529 nDoS);
530 Misbehaving(it->second, nDoS);
531 }
532 }
533 }
534
535 if (!state.CorruptionPossible()) {
536 pIndex->nStatus |= BLOCK_FAILED_VALID;
537 const auto &bpRegid = GetBlockBpRegid(block);
538 pCdMan->pBlockIndexDb->WriteBlockIndex(CDiskBlockIndex(pIndex, block, bpRegid));
539 setBlockIndexValid.erase(pIndex);
540 InvalidChainFound(pIndex);
541 }
542}
543
544bool InvalidateBlockIndex(CBlockIndex *pIndex) {
545 pIndex->nStatus |= BLOCK_FAILED_VALID;

Callers 1

ConnectTipFunction · 0.85

Calls 15

MisbehavingFunction · 0.85
InvalidChainFoundFunction · 0.85
IsInvalidMethod · 0.80
GetRejectCodeMethod · 0.80
GetRejectReasonMethod · 0.80
push_backMethod · 0.80
CorruptionPossibleMethod · 0.80
WriteBlockIndexMethod · 0.80
StateFunction · 0.50
CDiskBlockIndexClass · 0.50
findMethod · 0.45
GetBlockHashMethod · 0.45

Tested by

no test coverage detected