When responding to a getblocks message, only return inv's as long as we HAVE_DATA for blocks in the chain, and only for blocks that we are likely to not delete in the near future.
This fixes the issue mentioned here #6122 (comment).
When responding to a getblocks message, only return inv's as long as we HAVE_DATA for blocks in the chain, and only for blocks that we are likely to not delete in the near future.
This fixes the issue mentioned here #6122 (comment).
When responding to a getblocks message, only return inv's as
long as we HAVE_DATA for blocks in the chain, and only for blocks
that we aren't likely to delete in the near future.
4152 | @@ -4153,6 +4153,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, 4153 | LogPrint("net", " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); 4154 | break; 4155 | } 4156 | + // If pruning, don't inv blocks unless we have on disk and are likely to still have
Can't this check be done only once, before the loop? If it holds for the oldest block in the list, it will also hold for all further ones, I think?
That's very likely but not necessarily the case, because blocks can be written out of order to disk (so that we may have an older block but pruned a more recent block), and because we don't guarantee that we always have the last 288 blocks (though we try to, that assumption can break if there's a reorg). So it's possible, say, for a block at height tip-280 to be present but a block at height tip-279 to have been pruned.
Fair enough, and the test is cheap.
Pushed up a small fix (was using fHavePruned instead of fPruneMode in the test).