@@ -331,41 +331,6 @@ bool CBlockTreeDB::WritePAKList(const std::vector<std::vector<unsigned char> >&
331331 return Write (std::make_pair (DB_PAK, uint256S (" 1" )), offline_list) && Write (std::make_pair (DB_PAK, uint256S (" 2" )), online_list) && Write (std::make_pair (DB_PAK, uint256S (" 3" )), reject);
332332}
333333
334- /* * Note that we only get a conservative (lower) estimate of the max header height here,
335- * obtained by sampling the first 10,000 headers on disk (which are in random order) and
336- * taking the highest block we see. */
337- bool CBlockTreeDB::WalkBlockIndexGutsForMaxHeight (int * nHeight) {
338- std::unique_ptr<CDBIterator> pcursor (NewIterator ());
339- *nHeight = 0 ;
340- int i = 0 ;
341- pcursor->Seek (std::make_pair (DB_BLOCK_INDEX, uint256 ()));
342- while (pcursor->Valid ()) {
343- if (ShutdownRequested ()) return false ;
344- std::pair<uint8_t , uint256> key;
345- if (pcursor->GetKey (key) && key.first == DB_BLOCK_INDEX) {
346- i++;
347- if (i > 10'000 ) {
348- // Under the (accurate) assumption that the headers on disk are effectively in random height order,
349- // we have a good-enough (conservative) estimate of the max height very quickly, and don't need to
350- // waste more time. Shortcutting like this will cause us to keep a few extra headers, which is fine.
351- break ;
352- }
353- CDiskBlockIndex diskindex;
354- if (pcursor->GetValue (diskindex)) {
355- if (diskindex.nHeight > *nHeight) {
356- *nHeight = diskindex.nHeight ;
357- }
358- pcursor->Next ();
359- } else {
360- return error (" %s: failed to read value" , __func__);
361- }
362- } else {
363- break ;
364- }
365- }
366- return true ;
367- }
368-
369334const CBlockIndex *CBlockTreeDB::RegenerateFullIndex (const CBlockIndex *pindexTrimmed, CBlockIndex *pindexNew) const
370335{
371336 if (!pindexTrimmed->trimmed ()) {
0 commit comments