diff -uNr a/bitcoin/manifest b/bitcoin/manifest --- a/bitcoin/manifest 67267d31fbc4215b9d584711c5c333fdc8f34ae19ce8609d682e24a5a0ed74a4dacc45b1ce25ecccb235f431b877b04686a4e678725df71dffac20ec158f3a79 +++ b/bitcoin/manifest cfb0869447490ccb6a1b6a86944ad321bb6e71732e371075f89034d8ec25496edff2b465bb943db8692ebb3201d56a2015b6de5dc7eca6e6e662aaf4eb3fa492 @@ -43,3 +43,4 @@ 713908 bitcoin_checkblocks_cleanup jfw Let the -checkblocks option take a positive integer value to set the the check depth limit or zero for no limit. Drop the default from 2500 to 144. Break the implementation out from a long-winded CTxDB member function whose class context was irrelevant to it. Simplify its loop bounds (which revealed a corner case of genesis block possibly going unchecked), fix off-by-one on the nominal depth limit and make it count from the first *good* block found. Add progress reporting and improve error messages and commentary. Exit before loading other things when it fails. *NOTE:* This breaks CLI/config file compatibility with the prior sloppy undocumented situation where any -checkblocks value at all would enable full checking. 732505 bitcoin_getblockindex_etc_corrected jfw Add 'getblockindex' RPC command to view CBlockIndex objects as found in the memory block index and ultimately the database. Also corrects the InvalidChainFound log message for consistency with the safe mode warning changed in bitcoin_help_tuneups, and adds 'eatblock' to the safe mode command whitelist (since it's equivalent to receiving blocks from the network, which is not restricted in safe mode). (Prior patch version missed the newline in the log message.) 732509 bitcoin_drop_online_build jfw Remove code and comments pertaining to the ONLINE=1 option which fetched dependency libs from deedbot, and upgrade their manifest hashes from sha512sum to keksum format. +735223 bitcoin_response_size_limits_1 jfw Simple adjustments to prepare the code for more significant ones to improve response size limiting at the source. CBlockLocator::GetBlockIndex never returns NULL unless something is very wrong. Don't log when the getblocks response stops at the requested hash: it's uninteresting since that hash was already logged just before, and this allows simplifying loop bounds. Differentiate getheaders implementation between the null locator (single block) case and the normal loop. Always log starting heights for getblocks/getheaders rather than punting to -1 just because a non-null pointer wasn't immediately available. diff -uNr a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp --- a/bitcoin/src/main.cpp a30a8ae3e233c6f2b132532b85cedd41dc75defb30309abc5a58cd6d7c9c50b0880c88a6ba7b3440d590e21e29b0b90901b2959ac12c8558bb6ad50ab4d995e6 +++ b/bitcoin/src/main.cpp ea612c8910efd8e86d1a9eaa3668de9c8d586d495db3567b8e4115a070c3c6e8f07e60797411f0b511e4290877fa828c181bb730093812cc05f9db4620868345 @@ -1958,18 +1958,18 @@ CBlockIndex* pindex = locator.GetBlockIndex(); // Send the rest of the chain - if (pindex) - pindex = pindex->pnext; + if (!pindex) + { + printf("getblocks: null locator block index (shouldn't happen!)\n"); + return false; + } + unsigned int nStartHeight = pindex->nHeight + 1; + pindex = pindex->pnext; int nLimit = 500 + locator.GetDistanceBack(); unsigned int nBytes = 0; - printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit); - for (; pindex; pindex = pindex->pnext) + printf("getblocks %d to %s limit %d\n", nStartHeight, hashStop.ToString().c_str(), nLimit); + for (; pindex && pindex->GetBlockHash() != hashStop; pindex = pindex->pnext) { - if (pindex->GetBlockHash() == hashStop) - { - printf(" getblocks stopping at %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str(), nBytes); - break; - } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); CBlock block; block.ReadFromDisk(pindex, true); @@ -1993,6 +1993,7 @@ vRecv >> locator >> hashStop; CBlockIndex* pindex = NULL; + vector vHeaders; if (locator.IsNull()) { // If locator is null, return the hashStop block @@ -2000,23 +2001,28 @@ if (mi == mapBlockIndex.end()) return true; pindex = (*mi).second; + printf("getheaders %d at %s\n", pindex->nHeight, hashStop.ToString().c_str()); + vHeaders.push_back(pindex->GetBlockHeader()); } else { // Find the last block the caller has in the main chain pindex = locator.GetBlockIndex(); - if (pindex) - pindex = pindex->pnext; - } - - vector vHeaders; - int nLimit = 2000 + locator.GetDistanceBack(); - printf("getheaders %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit); - for (; pindex; pindex = pindex->pnext) - { - vHeaders.push_back(pindex->GetBlockHeader()); - if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) - break; + if (!pindex) + { + printf("getheaders: null locator block index (shouldn't happen!)\n"); + return false; + } + unsigned int nStartHeight = pindex->nHeight + 1; + pindex = pindex->pnext; + int nLimit = 2000 + locator.GetDistanceBack(); + printf("getheaders %d to %s limit %d\n", nStartHeight, hashStop.ToString().c_str(), nLimit); + for (; pindex; pindex = pindex->pnext) + { + vHeaders.push_back(pindex->GetBlockHeader()); + if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) + break; + } } pfrom->PushMessage("headers", vHeaders); }