Skip to content

Commit

Permalink
AcceptBlock() - not accept blocks from a forked chain that exceed the…
Browse files Browse the repository at this point in the history
… max reorg limit
  • Loading branch information
furszy committed Jan 30, 2019
1 parent 47759e1 commit 4219339
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main.cpp
Expand Up @@ -4560,15 +4560,22 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
const bool hasPIVInputs = !pivInputs.empty();
const bool hasZPIVInputs = !zPIVInputs.empty();

int readBlock = 0;
vector<CBigNum> vBlockSerials;
CBlock bl;
// Go backwards on the forked chain up to the split
do {
// Check if the forked chain is longer than the max reorg limit
if(readBlock == Params().MaxReorganizationDepth()){
// TODO: Remove this chain from disk.
return error("%s: forked chain longer than maximum reorg limit", __func__);
}

if(!ReadBlockFromDisk(bl, prev))
// Previous block not on disk
return error("%s: previous block %s not on disk", __func__, prev->GetBlockHash().GetHex());


// Increase amount of read blocks
readBlock++;
// Loop through every input from said block
for (CTransaction t : bl.vtx) {
for (CTxIn in: t.vin) {
Expand Down

0 comments on commit 4219339

Please sign in to comment.