|
16 | 16 | #include <chain.h>
|
17 | 17 | #include <chainparams.h>
|
18 | 18 | #include <compat/sanity.h>
|
19 |
| -#include <consensus/validation.h> |
20 | 19 | #include <fs.h>
|
21 | 20 | #include <hash.h>
|
22 | 21 | #include <httprpc.h>
|
|
32 | 31 | #include <net_permissions.h>
|
33 | 32 | #include <net_processing.h>
|
34 | 33 | #include <netbase.h>
|
| 34 | +#include <node/blockstorage.h> |
35 | 35 | #include <node/context.h>
|
36 | 36 | #include <node/ui_interface.h>
|
37 | 37 | #include <policy/feerate.h>
|
|
61 | 61 | #include <util/threadnames.h>
|
62 | 62 | #include <util/translation.h>
|
63 | 63 | #include <validation.h>
|
64 |
| - |
65 | 64 | #include <validationinterface.h>
|
66 | 65 | #include <walletinitinterface.h>
|
67 | 66 |
|
|
90 | 89 |
|
91 | 90 | static const bool DEFAULT_PROXYRANDOMIZE = true;
|
92 | 91 | static const bool DEFAULT_REST_ENABLE = false;
|
93 |
| -static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; |
94 | 92 |
|
95 | 93 | #ifdef WIN32
|
96 | 94 | // Win32 LevelDB doesn't use filedescriptors, and the ones used for
|
@@ -625,20 +623,6 @@ static void BlockNotifyGenesisWait(const CBlockIndex* pBlockIndex)
|
625 | 623 | }
|
626 | 624 | }
|
627 | 625 |
|
628 |
| -struct CImportingNow |
629 |
| -{ |
630 |
| - CImportingNow() { |
631 |
| - assert(fImporting == false); |
632 |
| - fImporting = true; |
633 |
| - } |
634 |
| - |
635 |
| - ~CImportingNow() { |
636 |
| - assert(fImporting == true); |
637 |
| - fImporting = false; |
638 |
| - } |
639 |
| -}; |
640 |
| - |
641 |
| - |
642 | 626 | // If we're using -prune with -reindex, then delete block files that will be ignored by the
|
643 | 627 | // reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
|
644 | 628 | // is missing, do the same here to delete any later block files after a gap. Also delete all
|
@@ -691,77 +675,6 @@ static void StartupNotify(const ArgsManager& args)
|
691 | 675 | }
|
692 | 676 | #endif
|
693 | 677 |
|
694 |
| -static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args) |
695 |
| -{ |
696 |
| - const CChainParams& chainparams = Params(); |
697 |
| - ScheduleBatchPriority(); |
698 |
| - |
699 |
| - { |
700 |
| - CImportingNow imp; |
701 |
| - |
702 |
| - // -reindex |
703 |
| - if (fReindex) { |
704 |
| - int nFile = 0; |
705 |
| - while (true) { |
706 |
| - FlatFilePos pos(nFile, 0); |
707 |
| - if (!fs::exists(GetBlockPosFilename(pos))) |
708 |
| - break; // No block files left to reindex |
709 |
| - FILE *file = OpenBlockFile(pos, true); |
710 |
| - if (!file) |
711 |
| - break; // This error is logged in OpenBlockFile |
712 |
| - LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile); |
713 |
| - ::ChainstateActive().LoadExternalBlockFile(chainparams, file, &pos); |
714 |
| - if (ShutdownRequested()) { |
715 |
| - LogPrintf("Shutdown requested. Exit %s\n", __func__); |
716 |
| - return; |
717 |
| - } |
718 |
| - nFile++; |
719 |
| - } |
720 |
| - pblocktree->WriteReindexing(false); |
721 |
| - fReindex = false; |
722 |
| - LogPrintf("Reindexing finished\n"); |
723 |
| - // To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked): |
724 |
| - ::ChainstateActive().LoadGenesisBlock(chainparams); |
725 |
| - } |
726 |
| - |
727 |
| - // -loadblock= |
728 |
| - for (const fs::path& path : vImportFiles) { |
729 |
| - FILE *file = fsbridge::fopen(path, "rb"); |
730 |
| - if (file) { |
731 |
| - LogPrintf("Importing blocks file %s...\n", path.string()); |
732 |
| - ::ChainstateActive().LoadExternalBlockFile(chainparams, file); |
733 |
| - if (ShutdownRequested()) { |
734 |
| - LogPrintf("Shutdown requested. Exit %s\n", __func__); |
735 |
| - return; |
736 |
| - } |
737 |
| - } else { |
738 |
| - LogPrintf("Warning: Could not open blocks file %s\n", path.string()); |
739 |
| - } |
740 |
| - } |
741 |
| - |
742 |
| - // scan for better chains in the block chain database, that are not yet connected in the active best chain |
743 |
| - |
744 |
| - // We can't hold cs_main during ActivateBestChain even though we're accessing |
745 |
| - // the chainman unique_ptrs since ABC requires us not to be holding cs_main, so retrieve |
746 |
| - // the relevant pointers before the ABC call. |
747 |
| - for (CChainState* chainstate : WITH_LOCK(::cs_main, return chainman.GetAll())) { |
748 |
| - BlockValidationState state; |
749 |
| - if (!chainstate->ActivateBestChain(state, chainparams, nullptr)) { |
750 |
| - LogPrintf("Failed to connect best block (%s)\n", state.ToString()); |
751 |
| - StartShutdown(); |
752 |
| - return; |
753 |
| - } |
754 |
| - } |
755 |
| - |
756 |
| - if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) { |
757 |
| - LogPrintf("Stopping after block import\n"); |
758 |
| - StartShutdown(); |
759 |
| - return; |
760 |
| - } |
761 |
| - } // End scope of CImportingNow |
762 |
| - chainman.ActiveChainstate().LoadMempool(args); |
763 |
| -} |
764 |
| - |
765 | 678 | /** Sanity checks
|
766 | 679 | * Ensure that Bitcoin is running in a usable environment with all
|
767 | 680 | * necessary library support.
|
|
0 commit comments