Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <policy/fees/estimator_args.h>7#include <common/args.h>8#include <util/log.h>10#include <system_error>12namespace {13constexpr const char* FEES_BASE_DIR{"fees"};14constexpr const char* BLOCK_POLICY_ESTIMATES_FILENAME{"block_policy_estimates.dat"};15constexpr const char* LEGACY_FEE_ESTIMATES_FILENAME{"fee_estimates.dat"};16constexpr const char* MEMPOOL_POLICY_ESTIMATOR_FILENAME{"mempool_policy_estimator.dat"};18fs::path LegacyFeeEstPath(const ArgsManager& argsman)19{20return argsman.GetDataDirNet() / LEGACY_FEE_ESTIMATES_FILENAME;21}22} // namespace24void MaybeMigrateLegacyFeeEstimates(const ArgsManager& argsman)25{26const fs::path legacy_path{LegacyFeeEstPath(argsman)};27const fs::path block_policy_path{BlockPolicyFeeEstPath(argsman)};28if (!fs::exists(legacy_path)) return;29std::error_code error;30if (fs::exists(block_policy_path)) {31fs::remove(legacy_path, error);32if (error) {33LogWarning("Failed to remove legacy fee estimates file %s: %s. Continuing anyway.", fs::PathToString(legacy_path), error.message());34return;35}36LogInfo("Removed legacy fee estimates file %s.", fs::PathToString(legacy_path));37return;38}39fs::create_directories(block_policy_path.parent_path(), error);40if (error) {41LogWarning("Failed to create block policy fee estimates directory %s: %s. Continuing without migration.", fs::PathToString(block_policy_path.parent_path()), error.message());42return;43}44fs::rename(legacy_path, block_policy_path, error);45if (error) {46LogWarning("Failed to migrate fee estimates from %s to %s: %s. Continuing with fresh estimates.", fs::PathToString(legacy_path), fs::PathToString(block_policy_path), error.message());47return;48}49LogInfo("Migrated fee estimates from %s to %s.", fs::PathToString(legacy_path), fs::PathToString(block_policy_path));50}52fs::path BlockPolicyFeeEstPath(const ArgsManager& argsman)53{54return argsman.GetDataDirNet() / FEES_BASE_DIR / BLOCK_POLICY_ESTIMATES_FILENAME;55}57fs::path MempoolPolicyEstimatorPath(const ArgsManager& argsman)58{59return argsman.GetDataDirNet() / FEES_BASE_DIR / MEMPOOL_POLICY_ESTIMATOR_FILENAME;60}