diff --git a/doc/release-process.md b/doc/release-process.md --- a/doc/release-process.md +++ b/doc/release-process.md @@ -24,6 +24,7 @@ - Regenerate manpages (run `contrib/devtools/gen-manpages.sh`, or for out-of-tree builds run `BUILDDIR=$PWD/build contrib/devtools/gen-manpages.sh`). - Update seeds as per [contrib/seeds/README.md](/contrib/seeds/README.md). + - Update [`src/chainparams.cpp`](/src/chainparams.cpp) m_assumed_blockchain_size and m_assumed_chain_state_size with the current size plus some overhead. 4. Add git tag for release a. Create the tag: `git tag vM.m.r` (M = major version, m = minor version, r = revision) diff --git a/src/chainparams.h b/src/chainparams.h --- a/src/chainparams.h +++ b/src/chainparams.h @@ -67,6 +67,15 @@ /** Policy: Filter transactions that do not match well-defined patterns */ bool RequireStandard() const { return fRequireStandard; } uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } + /** Minimum free space (in GB) needed for data directory */ + uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; } + /** + * Minimum free space (in GB) needed for data directory when pruned; Does + * not include prune target + */ + uint64_t AssumedChainStateSize() const { + return m_assumed_chain_state_size; + } /** * Make miner stop after a block is found. In RPC, don't return until * nGenProcLimit blocks are generated. @@ -92,6 +101,8 @@ CMessageHeader::MessageMagic netMagic; int nDefaultPort; uint64_t nPruneAfterHeight; + uint64_t m_assumed_blockchain_size; + uint64_t m_assumed_chain_state_size; std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; std::string cashaddrPrefix; diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -192,6 +192,8 @@ netMagic[3] = 0xe8; nDefaultPort = 8333; nPruneAfterHeight = 100000; + m_assumed_blockchain_size = 200; + m_assumed_chain_state_size = 3; genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN); @@ -414,6 +416,8 @@ netMagic[3] = 0xf4; nDefaultPort = 18333; nPruneAfterHeight = 1000; + m_assumed_blockchain_size = 20; + m_assumed_chain_state_size = 2; genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN); @@ -590,6 +594,8 @@ netMagic[3] = 0xfa; nDefaultPort = 18444; nPruneAfterHeight = 1000; + m_assumed_blockchain_size = 0; + m_assumed_chain_state_size = 0; genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -57,6 +57,12 @@ //! Choose network parameters. virtual void selectParams(const std::string &network) = 0; + //! Get the (assumed) blockchain size. + virtual uint64_t getAssumedBlockchainSize() = 0; + + //! Get the (assumed) chain state size. + virtual uint64_t getAssumedChainStateSize() = 0; + //! Get network name. virtual std::string getNetwork() = 0; diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -71,6 +71,12 @@ void selectParams(const std::string &network) override { SelectParams(network); } + uint64_t getAssumedBlockchainSize() override { + return Params().AssumedBlockchainSize(); + } + uint64_t getAssumedChainStateSize() override { + return Params().AssumedChainStateSize(); + } std::string getNetwork() override { return Params().NetworkIDString(); } void initLogging() override { InitLogging(); } void initParameterInteraction() override { InitParameterInteraction(); } diff --git a/src/qt/intro.h b/src/qt/intro.h --- a/src/qt/intro.h +++ b/src/qt/intro.h @@ -29,7 +29,8 @@ Q_OBJECT public: - explicit Intro(QWidget *parent = nullptr); + explicit Intro(QWidget *parent = nullptr, uint64_t blockchain_size = 0, + uint64_t chain_state_size = 0); ~Intro(); QString getDataDirectory(); @@ -72,6 +73,8 @@ QMutex mutex; bool signalled; QString pathToCheck; + uint64_t m_blockchain_size; + uint64_t m_chain_state_size; void startThread(); void checkPath(const QString &dataDir); diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -20,15 +20,6 @@ #include static const uint64_t GB_BYTES = 1000000000LL; -/** - * Minimum free space (in GB) needed for data directory. - */ -static const uint64_t BLOCK_CHAIN_SIZE = 220; -/** - * Minimum free space (in GB) needed for data directory when pruned; Does not - * include prune target. - */ -static const uint64_t CHAIN_STATE_SIZE = 4; /** * Total required space (in GB) depending on user choice (prune, not prune). */ @@ -117,22 +108,24 @@ Q_EMIT reply(replyStatus, replyMessage, freeBytesAvailable); } -Intro::Intro(QWidget *parent) - : QDialog(parent), ui(new Ui::Intro), thread(nullptr), signalled(false) { +Intro::Intro(QWidget *parent, uint64_t blockchain_size, + uint64_t chain_state_size) + : QDialog(parent), ui(new Ui::Intro), thread(nullptr), signalled(false), + m_blockchain_size(blockchain_size), m_chain_state_size(chain_state_size) { ui->setupUi(this); ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(tr(PACKAGE_NAME))); ui->storageLabel->setText(ui->storageLabel->text().arg(tr(PACKAGE_NAME))); ui->lblExplanation1->setText(ui->lblExplanation1->text() .arg(tr(PACKAGE_NAME)) - .arg(BLOCK_CHAIN_SIZE) + .arg(m_blockchain_size) .arg(2009) .arg(tr("Bitcoin"))); ui->lblExplanation2->setText( ui->lblExplanation2->text().arg(tr(PACKAGE_NAME))); uint64_t pruneTarget = std::max(0, gArgs.GetArg("-prune", 0)); - requiredSpace = BLOCK_CHAIN_SIZE; + requiredSpace = m_blockchain_size; QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it " "will grow over time."); @@ -147,7 +140,7 @@ } else { ui->lblExplanation3->setVisible(false); } - requiredSpace += CHAIN_STATE_SIZE; + requiredSpace += m_chain_state_size; ui->sizeWarningLabel->setText( tr("%1 will download and store a copy of the Bitcoin block chain.") .arg(tr(PACKAGE_NAME)) + @@ -200,9 +193,22 @@ gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false)) { - /* If current default data directory does not exist, let the user choose - * one */ - Intro intro; + /** + * Use selectParams here to guarantee Params() can be used by node + * interface. + */ + try { + node.selectParams(gArgs.GetChainName()); + } catch (const std::exception &) { + return false; + } + + /** + * If current default data directory does not exist, let the user choose + * one. + */ + Intro intro(nullptr, node.getAssumedBlockchainSize(), + node.getAssumedChainStateSize()); intro.setDataDirectory(dataDir); intro.setWindowIcon(QIcon(":icons/bitcoin"));