mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 14:50:54 +00:00
refactor: Change config section and key string literals into constants (#7095)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include <xrpld/app/misc/setup_HashRouter.h>
|
||||
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
|
||||
#include <xrpld/core/Config.h>
|
||||
#include <xrpld/core/ConfigSections.h>
|
||||
#include <xrpld/core/NetworkIDServiceImpl.h>
|
||||
#include <xrpld/overlay/Cluster.h>
|
||||
#include <xrpld/overlay/PeerSet.h>
|
||||
@@ -40,7 +39,6 @@
|
||||
#include <xrpld/rpc/detail/Pathfinder.h>
|
||||
#include <xrpld/shamap/NodeFamily.h>
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/ByteUtilities.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/MallocTrim.h>
|
||||
@@ -56,6 +54,8 @@
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/PropertyStream.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/core/ClosureCounter.h>
|
||||
#include <xrpl/core/HashRouter.h>
|
||||
#include <xrpl/core/Job.h>
|
||||
@@ -316,13 +316,14 @@ public:
|
||||
// PerfLog must be started before any other threads are launched.
|
||||
, perfLog_(
|
||||
perf::makePerfLog(
|
||||
perf::setupPerfLog(config_->section("perf"), config_->configDir),
|
||||
perf::setupPerfLog(config_->section(Sections::kPerf), config_->configDir),
|
||||
*this,
|
||||
logs_->journal("PerfLog"),
|
||||
[this] { signalStop("PerfLog"); }))
|
||||
, txMaster_(*this)
|
||||
, collectorManager_(
|
||||
makeCollectorManager(config_->section(SECTION_INSIGHT), logs_->journal("Collector")))
|
||||
, collectorManager_(makeCollectorManager(
|
||||
config_->section(Sections::kInsight),
|
||||
logs_->journal("Collector")))
|
||||
, jobQueue_(
|
||||
std::make_unique<JobQueue>(
|
||||
[](std::unique_ptr<Config> const& config) {
|
||||
@@ -864,7 +865,7 @@ public:
|
||||
megabytes(config_->getValueFor(SizedItem::BurstSize, std::nullopt)),
|
||||
dummyScheduler,
|
||||
0,
|
||||
config_->section(ConfigSection::importNodeDatabase()),
|
||||
config_->section(Sections::kImportNodeDatabase),
|
||||
j);
|
||||
|
||||
JLOG(j.warn()) << "Starting node import from '" << source->getName() << "' to '"
|
||||
@@ -1224,9 +1225,9 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
}
|
||||
return supported;
|
||||
}();
|
||||
Section const& downVoted = config_->section(SECTION_VETO_AMENDMENTS);
|
||||
Section const& downVoted = config_->section(Sections::kVetoAmendments);
|
||||
|
||||
Section const& upVoted = config_->section(SECTION_AMENDMENTS);
|
||||
Section const& upVoted = config_->section(Sections::kAmendments);
|
||||
|
||||
amendmentTable_ = makeAmendmentTable(
|
||||
*this,
|
||||
@@ -1295,7 +1296,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
|
||||
nodeIdentity_ = getNodeIdentity(*this, cmdline);
|
||||
|
||||
if (!cluster_->load(config().section(SECTION_CLUSTER_NODES)))
|
||||
if (!cluster_->load(config().section(Sections::kClusterNodes)))
|
||||
{
|
||||
JLOG(journal_.fatal()) << "Invalid entry in cluster configuration.";
|
||||
return false;
|
||||
@@ -1309,7 +1310,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
getWalletDB(),
|
||||
"ValidatorManifests",
|
||||
validatorKeys_.manifest,
|
||||
config().section(SECTION_VALIDATOR_KEY_REVOCATION).values()))
|
||||
config().section(Sections::kValidatorKeyRevocation).values()))
|
||||
{
|
||||
JLOG(journal_.fatal()) << "Invalid configured validator manifest.";
|
||||
return false;
|
||||
@@ -1320,7 +1321,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
// It is possible to have a valid ValidatorKeys object without
|
||||
// setting the signingKey or masterKey. This occurs if the
|
||||
// configuration file does not have either
|
||||
// SECTION_VALIDATOR_TOKEN or SECTION_VALIDATION_SEED section.
|
||||
// Sections::kValidatorToken or Sections::kValidationSeed section.
|
||||
|
||||
// masterKey for the configuration-file specified validator keys
|
||||
std::optional<PublicKey> localSigningKey;
|
||||
@@ -1330,8 +1331,8 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
// Setup trusted validators
|
||||
if (!validators_->load(
|
||||
localSigningKey,
|
||||
config().section(SECTION_VALIDATORS).values(),
|
||||
config().section(SECTION_VALIDATOR_LIST_KEYS).values(),
|
||||
config().section(Sections::kValidators).values(),
|
||||
config().section(Sections::kValidatorListKeys).values(),
|
||||
config().validatorListThreshold))
|
||||
{
|
||||
JLOG(journal_.fatal()) << "Invalid entry in validator configuration.";
|
||||
@@ -1339,9 +1340,9 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
}
|
||||
}
|
||||
|
||||
if (!validatorSites_->load(config().section(SECTION_VALIDATOR_LIST_SITES).values()))
|
||||
if (!validatorSites_->load(config().section(Sections::kValidatorListSites).values()))
|
||||
{
|
||||
JLOG(journal_.fatal()) << "Invalid entry in [" << SECTION_VALIDATOR_LIST_SITES << "]";
|
||||
JLOG(journal_.fatal()) << "Invalid entry in [" << Sections::kValidatorListSites << "]";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1439,7 +1440,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
//
|
||||
// Execute start up rpc commands.
|
||||
//
|
||||
for (auto const& cmd : config_->section(SECTION_RPC_STARTUP).lines())
|
||||
for (auto const& cmd : config_->section(Sections::kRpcStartup).lines())
|
||||
{
|
||||
json::Reader jrReader;
|
||||
json::Value jvCommand;
|
||||
@@ -1447,7 +1448,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
if (!jrReader.parse(cmd, jvCommand))
|
||||
{
|
||||
JLOG(journal_.fatal())
|
||||
<< "Couldn't parse entry in [" << SECTION_RPC_STARTUP << "]: '" << cmd;
|
||||
<< "Couldn't parse entry in [" << Sections::kRpcStartup << "]: '" << cmd;
|
||||
}
|
||||
|
||||
if (!config_->quiet())
|
||||
@@ -1503,7 +1504,7 @@ ApplicationImp::start(bool withTimers)
|
||||
overlay_->start();
|
||||
|
||||
if (grpcServer_->start())
|
||||
fixConfigPorts(*config_, {{SECTION_PORT_GRPC, grpcServer_->getEndpoint()}});
|
||||
fixConfigPorts(*config_, {{Sections::kPortGrpc, grpcServer_->getEndpoint()}});
|
||||
|
||||
ledgerCleaner_->start();
|
||||
perfLog_->start();
|
||||
@@ -2170,12 +2171,12 @@ fixConfigPorts(Config& config, Endpoints const& endpoints)
|
||||
continue;
|
||||
|
||||
auto& section = config[name];
|
||||
auto const optPort = section.get("port");
|
||||
auto const optPort = section.get(Keys::kPort);
|
||||
if (optPort)
|
||||
{
|
||||
std::uint16_t const port = beast::lexicalCast<std::uint16_t>(*optPort);
|
||||
if (port == 0u)
|
||||
section.set("port", std::to_string(ep.port()));
|
||||
section.set(Keys::kPort, std::to_string(ep.port()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user