mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge bitcoin/bitcoin#27576: kernel: Remove args, settings, chainparams, chainparamsbase from kernel library
db77f87c63scripted-diff: move settings to common namespace (TheCharlatan)c27e4bdc35move-only: Move settings to the common library (TheCharlatan)c2dae5d7d8kernel: Remove chainparams, chainparamsbase, args, settings from kernel library (TheCharlatan)05870b1c92refactor: Remove gArgs access from validation.cpp (TheCharlatan)8789b11114refactor: Add path argument to FindSnapshotChainstateDir (TheCharlatan)ef95be334frefactor: Add stop_at_height option in ChainstateManager (TheCharlatan) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/27587 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". --- This completes the removal of the node's chainparams, chainparamsbase, args and settings files and their respective classes from the kernel library. This is the last pull request in a long series working towards decoupling the `ArgsManager` and the `gArgs` global from kernel code. These prior pull requests are: https://github.com/bitcoin/bitcoin/pull/26177 https://github.com/bitcoin/bitcoin/pull/27125 https://github.com/bitcoin/bitcoin/pull/25527 https://github.com/bitcoin/bitcoin/pull/25487 https://github.com/bitcoin/bitcoin/pull/25290 ACKs for top commit: MarcoFalke: lgtm ACKdb77f87c63🍄 hebasto: ACKdb77f87c63, I have reviewed the code and it looks OK. ryanofsky: Code review ACKdb77f87c63. Looks great! Tree-SHA512: cbfbd705d056f2f10f16810d4f869eb152362fff2c5ddae5e1ac6785deae095588e52ad48b29d921962b085e51de1e0ecab6e50f46149ffe3c16250608a2c93a
This commit is contained in:
@@ -37,6 +37,8 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManage
|
||||
|
||||
if (auto value{args.GetIntArg("-maxtipage")}) opts.max_tip_age = std::chrono::seconds{*value};
|
||||
|
||||
if (auto value{args.GetIntArg("-stopatheight")}) opts.stop_at_height = *value;
|
||||
|
||||
ReadDatabaseArgs(args, opts.block_tree_db);
|
||||
ReadDatabaseArgs(args, opts.coins_db);
|
||||
ReadCoinsViewArgs(args, opts.coins_view);
|
||||
|
||||
@@ -125,17 +125,17 @@ public:
|
||||
bool isSettingIgnored(const std::string& name) override
|
||||
{
|
||||
bool ignored = false;
|
||||
args().LockSettings([&](util::Settings& settings) {
|
||||
if (auto* options = util::FindKey(settings.command_line_options, name)) {
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
if (auto* options = common::FindKey(settings.command_line_options, name)) {
|
||||
ignored = !options->empty();
|
||||
}
|
||||
});
|
||||
return ignored;
|
||||
}
|
||||
util::SettingsValue getPersistentSetting(const std::string& name) override { return args().GetPersistentSetting(name); }
|
||||
void updateRwSetting(const std::string& name, const util::SettingsValue& value) override
|
||||
common::SettingsValue getPersistentSetting(const std::string& name) override { return args().GetPersistentSetting(name); }
|
||||
void updateRwSetting(const std::string& name, const common::SettingsValue& value) override
|
||||
{
|
||||
args().LockSettings([&](util::Settings& settings) {
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.rw_settings.erase(name);
|
||||
} else {
|
||||
@@ -144,9 +144,9 @@ public:
|
||||
});
|
||||
args().WriteSettingsFile();
|
||||
}
|
||||
void forceSetting(const std::string& name, const util::SettingsValue& value) override
|
||||
void forceSetting(const std::string& name, const common::SettingsValue& value) override
|
||||
{
|
||||
args().LockSettings([&](util::Settings& settings) {
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.forced_settings.erase(name);
|
||||
} else {
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
void resetSettings() override
|
||||
{
|
||||
args().WriteSettingsFile(/*errors=*/nullptr, /*backup=*/true);
|
||||
args().LockSettings([&](util::Settings& settings) {
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
settings.rw_settings.clear();
|
||||
});
|
||||
args().WriteSettingsFile();
|
||||
@@ -744,27 +744,27 @@ public:
|
||||
RPCRunLater(name, std::move(fn), seconds);
|
||||
}
|
||||
int rpcSerializationFlags() override { return RPCSerializationFlags(); }
|
||||
util::SettingsValue getSetting(const std::string& name) override
|
||||
common::SettingsValue getSetting(const std::string& name) override
|
||||
{
|
||||
return args().GetSetting(name);
|
||||
}
|
||||
std::vector<util::SettingsValue> getSettingsList(const std::string& name) override
|
||||
std::vector<common::SettingsValue> getSettingsList(const std::string& name) override
|
||||
{
|
||||
return args().GetSettingsList(name);
|
||||
}
|
||||
util::SettingsValue getRwSetting(const std::string& name) override
|
||||
common::SettingsValue getRwSetting(const std::string& name) override
|
||||
{
|
||||
util::SettingsValue result;
|
||||
args().LockSettings([&](const util::Settings& settings) {
|
||||
if (const util::SettingsValue* value = util::FindKey(settings.rw_settings, name)) {
|
||||
common::SettingsValue result;
|
||||
args().LockSettings([&](const common::Settings& settings) {
|
||||
if (const common::SettingsValue* value = common::FindKey(settings.rw_settings, name)) {
|
||||
result = *value;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
bool updateRwSetting(const std::string& name, const util::SettingsValue& value, bool write) override
|
||||
bool updateRwSetting(const std::string& name, const common::SettingsValue& value, bool write) override
|
||||
{
|
||||
args().LockSettings([&](util::Settings& settings) {
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.rw_settings.erase(name);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <node/utxo_snapshot.h>
|
||||
|
||||
#include <common/args.h>
|
||||
#include <logging.h>
|
||||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
@@ -82,10 +81,10 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
|
||||
return base_blockhash;
|
||||
}
|
||||
|
||||
std::optional<fs::path> FindSnapshotChainstateDir()
|
||||
std::optional<fs::path> FindSnapshotChainstateDir(const fs::path& data_dir)
|
||||
{
|
||||
fs::path possible_dir =
|
||||
gArgs.GetDataDirNet() / fs::u8path(strprintf("chainstate%s", SNAPSHOT_CHAINSTATE_SUFFIX));
|
||||
data_dir / fs::u8path(strprintf("chainstate%s", SNAPSHOT_CHAINSTATE_SUFFIX));
|
||||
|
||||
if (fs::exists(possible_dir)) {
|
||||
return possible_dir;
|
||||
|
||||
@@ -67,7 +67,7 @@ constexpr std::string_view SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot";
|
||||
|
||||
|
||||
//! Return a path to the snapshot-based chainstate dir, if one exists.
|
||||
std::optional<fs::path> FindSnapshotChainstateDir();
|
||||
std::optional<fs::path> FindSnapshotChainstateDir(const fs::path& data_dir);
|
||||
|
||||
} // namespace node
|
||||
|
||||
|
||||
Reference in New Issue
Block a user