Reject headers that build on an invalid parent
This commit is contained in:
parent
203632d20b
commit
3497022347
1 changed files with 6 additions and 0 deletions
|
@ -449,6 +449,10 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<CBl
|
||||||
// are not yet downloaded and not in flight to vBlocks. In the mean time, update
|
// are not yet downloaded and not in flight to vBlocks. In the mean time, update
|
||||||
// pindexLastCommonBlock as long as all ancestors are already downloaded.
|
// pindexLastCommonBlock as long as all ancestors are already downloaded.
|
||||||
BOOST_FOREACH(CBlockIndex* pindex, vToFetch) {
|
BOOST_FOREACH(CBlockIndex* pindex, vToFetch) {
|
||||||
|
if (!pindex->IsValid(BLOCK_VALID_TREE)) {
|
||||||
|
// We consider the chain that this peer is on invalid.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
||||||
if (pindex->nChainTx)
|
if (pindex->nChainTx)
|
||||||
state->pindexLastCommonBlock = pindex;
|
state->pindexLastCommonBlock = pindex;
|
||||||
|
@ -2563,6 +2567,8 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
||||||
if (mi == mapBlockIndex.end())
|
if (mi == mapBlockIndex.end())
|
||||||
return state.DoS(10, error("%s : prev block not found", __func__), 0, "bad-prevblk");
|
return state.DoS(10, error("%s : prev block not found", __func__), 0, "bad-prevblk");
|
||||||
pindexPrev = (*mi).second;
|
pindexPrev = (*mi).second;
|
||||||
|
if (pindexPrev->nStatus & BLOCK_FAILED_MASK)
|
||||||
|
return state.DoS(100, error("%s : prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
|
|
Loading…
Reference in a new issue