diff --git a/include/xrpl/basics/BasicConfig.h b/include/xrpl/basics/BasicConfig.h index a93a36d847..c6d976fc08 100644 --- a/include/xrpl/basics/BasicConfig.h +++ b/include/xrpl/basics/BasicConfig.h @@ -376,187 +376,173 @@ getIfExists(Section const& section, std::string const& name, bool& v) //------------------------------------------------------------------------------ -// Section name constants. -inline constexpr auto kSECTION_AMENDMENTS = "amendments"; -inline constexpr auto kSECTION_AMENDMENT_MAJORITY_TIME = "amendment_majority_time"; -inline constexpr auto kSECTION_BETA_RPC_API = "beta_rpc_api"; -inline constexpr auto kSECTION_CLUSTER_NODES = "cluster_nodes"; -inline constexpr auto kSECTION_COMPRESSION = "compression"; -inline constexpr auto kSECTION_CRAWL = "crawl"; -inline constexpr auto kSECTION_DATABASE_PATH = "database_path"; -inline constexpr auto kSECTION_DEBUG_LOGFILE = "debug_logfile"; -inline constexpr auto kSECTION_ELB_SUPPORT = "elb_support"; -inline constexpr auto kSECTION_FEE_DEFAULT = "fee_default"; -inline constexpr auto kSECTION_FEATURES = "features"; -inline constexpr auto kSECTION_FETCH_DEPTH = "fetch_depth"; -inline constexpr auto kSECTION_HASHROUTER = "hashrouter"; -inline constexpr auto kSECTION_IMPORT_NODE_DATABASE = "import_db"; -inline constexpr auto kSECTION_INSIGHT = "insight"; -inline constexpr auto kSECTION_IO_WORKERS = "io_workers"; -inline constexpr auto kSECTION_IPS = "ips"; -inline constexpr auto kSECTION_IPS_FIXED = "ips_fixed"; -inline constexpr auto kSECTION_LEDGER_HISTORY = "ledger_history"; -inline constexpr auto kSECTION_LEDGER_REPLAY = "ledger_replay"; -inline constexpr auto kSECTION_LEDGER_TX_TABLES = "ledger_tx_tables"; -inline constexpr auto kSECTION_MAX_TRANSACTIONS = "max_transactions"; -inline constexpr auto kSECTION_NETWORK_ID = "network_id"; -inline constexpr auto kSECTION_NETWORK_QUORUM = "network_quorum"; -inline constexpr auto kSECTION_NODE_DATABASE = "node_db"; -inline constexpr auto kSECTION_NODE_SEED = "node_seed"; -inline constexpr auto kSECTION_NODE_SIZE = "node_size"; -inline constexpr auto kSECTION_OVERLAY = "overlay"; -inline constexpr auto kSECTION_PATH_SEARCH_OLD = "path_search_old"; -inline constexpr auto kSECTION_PATH_SEARCH = "path_search"; -inline constexpr auto kSECTION_PATH_SEARCH_FAST = "path_search_fast"; -inline constexpr auto kSECTION_PATH_SEARCH_MAX = "path_search_max"; -inline constexpr auto kSECTION_PEER_PRIVATE = "peer_private"; -inline constexpr auto kSECTION_PEERS_MAX = "peers_max"; -inline constexpr auto kSECTION_PEERS_IN_MAX = "peers_in_max"; -inline constexpr auto kSECTION_PEERS_OUT_MAX = "peers_out_max"; -inline constexpr auto kSECTION_PERF = "perf"; -inline constexpr auto kSECTION_PORT_GRPC = "port_grpc"; -inline constexpr auto kSECTION_PORT_PEER = "port_peer"; -inline constexpr auto kSECTION_PORT_RPC = "port_rpc"; -inline constexpr auto kSECTION_PORT_WS = "port_ws"; -inline constexpr auto kSECTION_PORT_WSS_ADMIN = "port_wss_admin"; -inline constexpr auto kSECTION_PREFETCH_WORKERS = "prefetch_workers"; -inline constexpr auto kSECTION_REDUCE_RELAY = "reduce_relay"; -inline constexpr auto kSECTION_RELATIONAL_DB = "relational_db"; -inline constexpr auto kSECTION_RELAY_PROPOSALS = "relay_proposals"; -inline constexpr auto kSECTION_RELAY_VALIDATIONS = "relay_validations"; -inline constexpr auto kSECTION_RPC_STARTUP = "rpc_startup"; -inline constexpr auto kSECTION_SERVER = "server"; -inline constexpr auto kSECTION_SERVER_DOMAIN = "server_domain"; -inline constexpr auto kSECTION_SIGNING_SUPPORT = "signing_support"; -inline constexpr auto kSECTION_SNTP = "sntp_servers"; -inline constexpr auto kSECTION_SQDB = "sqdb"; -inline constexpr auto kSECTION_SQLITE = "sqlite"; -inline constexpr auto kSECTION_SSL_VERIFY = "ssl_verify"; -inline constexpr auto kSECTION_SSL_VERIFY_FILE = "ssl_verify_file"; -inline constexpr auto kSECTION_SSL_VERIFY_DIR = "ssl_verify_dir"; -inline constexpr auto kSECTION_SWEEP_INTERVAL = "sweep_interval"; -inline constexpr auto kSECTION_TRANSACTION_QUEUE = "transaction_queue"; -inline constexpr auto kSECTION_VALIDATORS_FILE = "validators_file"; -inline constexpr auto kSECTION_VALIDATION_SEED = "validation_seed"; -inline constexpr auto kSECTION_VALIDATOR_KEYS = "validator_keys"; -inline constexpr auto kSECTION_VALIDATOR_KEY_REVOCATION = "validator_key_revocation"; -inline constexpr auto kSECTION_VALIDATOR_LIST_KEYS = "validator_list_keys"; -inline constexpr auto kSECTION_VALIDATOR_LIST_SITES = "validator_list_sites"; -inline constexpr auto kSECTION_VALIDATOR_LIST_THRESHOLD = "validator_list_threshold"; -inline constexpr auto kSECTION_VALIDATORS = "validators"; -inline constexpr auto kSECTION_VALIDATOR_TOKEN = "validator_token"; -inline constexpr auto kSECTION_VETO_AMENDMENTS = "veto_amendments"; -inline constexpr auto kSECTION_VL = "vl"; -inline constexpr auto kSECTION_VOTING = "voting"; -inline constexpr auto kSECTION_WORKERS = "workers"; +struct Sections +{ + static constexpr auto kAMENDMENTS = "amendments"; + static constexpr auto kAMENDMENT_MAJORITY_TIME = "amendment_majority_time"; + static constexpr auto kBETA_RPC_API = "beta_rpc_api"; + static constexpr auto kCLUSTER_NODES = "cluster_nodes"; + static constexpr auto kCOMPRESSION = "compression"; + static constexpr auto kCRAWL = "crawl"; + static constexpr auto kDATABASE_PATH = "database_path"; + static constexpr auto kDEBUG_LOGFILE = "debug_logfile"; + static constexpr auto kELB_SUPPORT = "elb_support"; + static constexpr auto kFEATURES = "features"; + static constexpr auto kFEE_DEFAULT = "fee_default"; + static constexpr auto kFETCH_DEPTH = "fetch_depth"; + static constexpr auto kHASHROUTER = "hashrouter"; + static constexpr auto kIMPORT_NODE_DATABASE = "import_db"; + static constexpr auto kINSIGHT = "insight"; + static constexpr auto kIO_WORKERS = "io_workers"; + static constexpr auto kIPS = "ips"; + static constexpr auto kIPS_FIXED = "ips_fixed"; + static constexpr auto kLEDGER_HISTORY = "ledger_history"; + static constexpr auto kLEDGER_REPLAY = "ledger_replay"; + static constexpr auto kLEDGER_TX_TABLES = "ledger_tx_tables"; + static constexpr auto kMAX_TRANSACTIONS = "max_transactions"; + static constexpr auto kNETWORK_ID = "network_id"; + static constexpr auto kNETWORK_QUORUM = "network_quorum"; + static constexpr auto kNODE_DATABASE = "node_db"; + static constexpr auto kNODE_SEED = "node_seed"; + static constexpr auto kNODE_SIZE = "node_size"; + static constexpr auto kOVERLAY = "overlay"; + static constexpr auto kPATH_SEARCH = "path_search"; + static constexpr auto kPATH_SEARCH_FAST = "path_search_fast"; + static constexpr auto kPATH_SEARCH_MAX = "path_search_max"; + static constexpr auto kPATH_SEARCH_OLD = "path_search_old"; + static constexpr auto kPEER_PRIVATE = "peer_private"; + static constexpr auto kPEERS_IN_MAX = "peers_in_max"; + static constexpr auto kPEERS_MAX = "peers_max"; + static constexpr auto kPEERS_OUT_MAX = "peers_out_max"; + static constexpr auto kPERF = "perf"; + static constexpr auto kPORT_GRPC = "port_grpc"; + static constexpr auto kPORT_PEER = "port_peer"; + static constexpr auto kPORT_RPC = "port_rpc"; + static constexpr auto kPORT_WS = "port_ws"; + static constexpr auto kPORT_WSS_ADMIN = "port_wss_admin"; + static constexpr auto kPREFETCH_WORKERS = "prefetch_workers"; + static constexpr auto kREDUCE_RELAY = "reduce_relay"; + static constexpr auto kRELATIONAL_DB = "relational_db"; + static constexpr auto kRELAY_PROPOSALS = "relay_proposals"; + static constexpr auto kRELAY_VALIDATIONS = "relay_validations"; + static constexpr auto kRPC_STARTUP = "rpc_startup"; + static constexpr auto kSERVER = "server"; + static constexpr auto kSERVER_DOMAIN = "server_domain"; + static constexpr auto kSIGNING_SUPPORT = "signing_support"; + static constexpr auto kSNTP = "sntp_servers"; + static constexpr auto kSQDB = "sqdb"; + static constexpr auto kSQLITE = "sqlite"; + static constexpr auto kSSL_VERIFY = "ssl_verify"; + static constexpr auto kSSL_VERIFY_DIR = "ssl_verify_dir"; + static constexpr auto kSSL_VERIFY_FILE = "ssl_verify_file"; + static constexpr auto kSWEEP_INTERVAL = "sweep_interval"; + static constexpr auto kTRANSACTION_QUEUE = "transaction_queue"; + static constexpr auto kVALIDATION_SEED = "validation_seed"; + static constexpr auto kVALIDATOR_KEYS = "validator_keys"; + static constexpr auto kVALIDATOR_KEY_REVOCATION = "validator_key_revocation"; + static constexpr auto kVALIDATOR_LIST_KEYS = "validator_list_keys"; + static constexpr auto kVALIDATOR_LIST_SITES = "validator_list_sites"; + static constexpr auto kVALIDATOR_LIST_THRESHOLD = "validator_list_threshold"; + static constexpr auto kVALIDATOR_TOKEN = "validator_token"; + static constexpr auto kVALIDATORS = "validators"; + static constexpr auto kVALIDATORS_FILE = "validators_file"; + static constexpr auto kVETO_AMENDMENTS = "veto_amendments"; + static constexpr auto kVL = "vl"; + static constexpr auto kVOTING = "voting"; + static constexpr auto kWORKERS = "workers"; +}; -// Key name constants: nodestore backend. -inline constexpr auto kKEY_ADVISORY_DELETE = "advisory_delete"; -inline constexpr auto kKEY_AGE_THRESHOLD_SECONDS = "age_threshold_seconds"; -inline constexpr auto kKEY_BACK_OFF = "backOff"; -inline constexpr auto kKEY_BACK_OFF_MILLISECONDS = "back_off_milliseconds"; -inline constexpr auto kKEY_BBT_OPTIONS = "bbt_options"; -inline constexpr auto kKEY_BG_THREADS = "bg_threads"; -inline constexpr auto kKEY_BLOCK_SIZE = "block_size"; -inline constexpr auto kKEY_CACHE_MB = "cache_mb"; -inline constexpr auto kKEY_DELETE_BATCH = "delete_batch"; -inline constexpr auto kKEY_EARLIEST_SEQ = "earliest_seq"; -inline constexpr auto kKEY_FAST_LOAD = "fast_load"; -inline constexpr auto kKEY_FILE_SIZE_MB = "file_size_mb"; -inline constexpr auto kKEY_FILE_SIZE_MULT = "file_size_mult"; -inline constexpr auto kKEY_FILTER_BITS = "filter_bits"; -inline constexpr auto kKEY_FILTER_FULL = "filter_full"; -inline constexpr auto kKEY_HARD_SET = "hard_set"; -inline constexpr auto kKEY_HIGH_THREADS = "high_threads"; -inline constexpr auto kKEY_NUDB_BLOCK_SIZE = "nudb_block_size"; -inline constexpr auto kKEY_ONLINE_DELETE = "online_delete"; -inline constexpr auto kKEY_OPEN_FILES = "open_files"; -inline constexpr auto kKEY_OPTIONS = "options"; -inline constexpr auto kKEY_PATH = "path"; -inline constexpr auto kKEY_RECOVERY_WAIT_SECONDS = "recovery_wait_seconds"; -inline constexpr auto kKEY_RQ_BUNDLE = "rq_bundle"; -inline constexpr auto kKEY_TYPE = "type"; -inline constexpr auto kKEY_UNIVERSAL_COMPACTION = "universal_compaction"; -inline constexpr auto kKEY_USE_TX_TABLES = "use_tx_tables"; - -// Key name constants: port configuration. -inline constexpr auto kKEY_ADMIN = "admin"; -inline constexpr auto kKEY_ADMIN_PASSWORD = "admin_password"; -inline constexpr auto kKEY_ADMIN_USER = "admin_user"; -inline constexpr auto kKEY_CLIENT_MAX_WINDOW_BITS = "client_max_window_bits"; -inline constexpr auto kKEY_CLIENT_NO_CONTEXT_TAKEOVER = "client_no_context_takeover"; -inline constexpr auto kKEY_COMPRESS_LEVEL = "compress_level"; -inline constexpr auto kKEY_IP = "ip"; -inline constexpr auto kKEY_LIMIT = "limit"; -inline constexpr auto kKEY_MEMORY_LEVEL = "memory_level"; -inline constexpr auto kKEY_PASSWORD = "password"; -inline constexpr auto kKEY_PERMESSAGE_DEFLATE = "permessage_deflate"; -inline constexpr auto kKEY_PORT = "port"; -inline constexpr auto kKEY_PROTOCOL = "protocol"; -inline constexpr auto kKEY_SECURE_GATEWAY = "secureGateway"; -inline constexpr auto kKEY_SEND_QUEUE_LIMIT = "send_queue_limit"; -inline constexpr auto kKEY_SERVER_MAX_WINDOW_BITS = "server_max_window_bits"; -inline constexpr auto kKEY_SERVER_NO_CONTEXT_TAKEOVER = "server_no_context_takeover"; -inline constexpr auto kKEY_SSL_CERT = "ssl_cert"; -inline constexpr auto kKEY_SSL_CERT_CHAIN = "ssl_cert_chain"; -inline constexpr auto kKEY_SSL_CHAIN = "ssl_chain"; -inline constexpr auto kKEY_SSL_CIPHERS = "ssl_ciphers"; -inline constexpr auto kKEY_SSL_CLIENT_CA = "ssl_client_ca"; -inline constexpr auto kKEY_SSL_KEY = "ssl_key"; -inline constexpr auto kKEY_USER = "user"; - -// Key name constants: reduce_relay section. -inline constexpr auto kKEY_TX_ENABLE = "tx_enable"; -inline constexpr auto kKEY_TX_METRICS = "tx_metrics"; -inline constexpr auto kKEY_TX_MIN_PEERS = "tx_min_peers"; -inline constexpr auto kKEY_TX_RELAY_PERCENTAGE = "tx_relay_percentage"; -inline constexpr auto kKEY_VP_BASE_SQUELCH_ENABLE = "vp_base_squelch_enable"; -inline constexpr auto kKEY_VP_BASE_SQUELCH_MAX_SELECTED_PEERS = - "vp_base_squelch_max_selected_peers"; -inline constexpr auto kKEY_VP_ENABLE = "vp_enable"; - -// Key name constants: overlay section. -inline constexpr auto kKEY_COUNTS = "counts"; -inline constexpr auto kKEY_MAX_DIVERGED_TIME = "max_diverged_time"; -inline constexpr auto kKEY_MAX_UNKNOWN_TIME = "max_unknown_time"; -inline constexpr auto kKEY_OVERLAY = "overlay"; -inline constexpr auto kKEY_SERVER = "server"; -inline constexpr auto kKEY_UNL = "unl"; - -// Key name constants: transaction_queue section. -inline constexpr auto kKEY_LEDGERS_IN_QUEUE = "ledgers_in_queue"; -inline constexpr auto kKEY_MAX_LEDGER_COUNTS_TO_STORE = "max_ledger_counts_to_store"; -inline constexpr auto kKEY_MIN_LEDGERS_TO_COMPUTE_SIZE_LIMIT = "min_ledgers_to_compute_size_limit"; -inline constexpr auto kKEY_MINIMUM_QUEUE_SIZE = "minimum_queue_size"; -inline constexpr auto kKEY_MINIMUM_TXN_IN_LEDGER = "minimum_txn_in_ledger"; -inline constexpr auto kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE = "minimum_txn_in_ledger_standalone"; -inline constexpr auto kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT = "normal_consensus_increase_percent"; -inline constexpr auto kKEY_RETRY_SEQUENCE_PERCENT = "retry_sequence_percent"; -inline constexpr auto kKEY_TARGET_TXN_IN_LEDGER = "target_txn_in_ledger"; - -// Key name constants: hashrouter section. -inline constexpr auto kKEY_HOLD_TIME = "hold_time"; -inline constexpr auto kKEY_RELAY_TIME = "relay_time"; - -// Key name constants: sqlite section. -inline constexpr auto kKEY_JOURNAL_MODE = "journal_mode"; -inline constexpr auto kKEY_JOURNAL_SIZE_LIMIT = "journal_size_limit"; -inline constexpr auto kKEY_PAGE_SIZE = "page_size"; -inline constexpr auto kKEY_SAFETY_LEVEL = "safety_level"; -inline constexpr auto kKEY_SYNCHRONOUS = "synchronous"; -inline constexpr auto kKEY_TEMP_STORE = "temp_store"; - -// Key name constants: insight section. -inline constexpr auto kKEY_ADDRESS = "address"; -inline constexpr auto kKEY_BACKEND = "backend"; -inline constexpr auto kKEY_PREFIX = "prefix"; - -// Key name constants: voting section. -inline constexpr auto kKEY_ACCOUNT_RESERVE = "account_reserve"; -inline constexpr auto kKEY_OWNER_RESERVE = "owner_reserve"; -inline constexpr auto kKEY_REFERENCE_FEE = "reference_fee"; - -// Key name constants: perflog section. -inline constexpr auto kKEY_LOG_INTERVAL = "log_interval"; +struct Keys +{ + static constexpr auto kACCOUNT_RESERVE = "account_reserve"; + static constexpr auto kADDRESS = "address"; + static constexpr auto kADMIN = "admin"; + static constexpr auto kADMIN_PASSWORD = "admin_password"; + static constexpr auto kADMIN_USER = "admin_user"; + static constexpr auto kADVISORY_DELETE = "advisory_delete"; + static constexpr auto kAGE_THRESHOLD_SECONDS = "age_threshold_seconds"; + static constexpr auto kBACK_OFF = "backOff"; + static constexpr auto kBACK_OFF_MILLISECONDS = "back_off_milliseconds"; + static constexpr auto kBACKEND = "backend"; + static constexpr auto kBBT_OPTIONS = "bbt_options"; + static constexpr auto kBG_THREADS = "bg_threads"; + static constexpr auto kBLOCK_SIZE = "block_size"; + static constexpr auto kCACHE_MB = "cache_mb"; + static constexpr auto kCLIENT_MAX_WINDOW_BITS = "client_max_window_bits"; + static constexpr auto kCLIENT_NO_CONTEXT_TAKEOVER = "client_no_context_takeover"; + static constexpr auto kCOMPRESS_LEVEL = "compress_level"; + static constexpr auto kCOUNTS = "counts"; + static constexpr auto kDELETE_BATCH = "delete_batch"; + static constexpr auto kEARLIEST_SEQ = "earliest_seq"; + static constexpr auto kFAST_LOAD = "fast_load"; + static constexpr auto kFILE_SIZE_MB = "file_size_mb"; + static constexpr auto kFILE_SIZE_MULT = "file_size_mult"; + static constexpr auto kFILTER_BITS = "filter_bits"; + static constexpr auto kFILTER_FULL = "filter_full"; + static constexpr auto kHARD_SET = "hard_set"; + static constexpr auto kHIGH_THREADS = "high_threads"; + static constexpr auto kHOLD_TIME = "hold_time"; + static constexpr auto kIP = "ip"; + static constexpr auto kJOURNAL_MODE = "journal_mode"; + static constexpr auto kJOURNAL_SIZE_LIMIT = "journal_size_limit"; + static constexpr auto kLEDGERS_IN_QUEUE = "ledgers_in_queue"; + static constexpr auto kLIMIT = "limit"; + static constexpr auto kLOG_INTERVAL = "log_interval"; + static constexpr auto kMAX_DIVERGED_TIME = "max_diverged_time"; + static constexpr auto kMAX_LEDGER_COUNTS_TO_STORE = "max_ledger_counts_to_store"; + static constexpr auto kMAX_UNKNOWN_TIME = "max_unknown_time"; + static constexpr auto kMEMORY_LEVEL = "memory_level"; + static constexpr auto kMIN_LEDGERS_TO_COMPUTE_SIZE_LIMIT = "min_ledgers_to_compute_size_limit"; + static constexpr auto kMINIMUM_QUEUE_SIZE = "minimum_queue_size"; + static constexpr auto kMINIMUM_TXN_IN_LEDGER = "minimum_txn_in_ledger"; + static constexpr auto kMINIMUM_TXN_IN_LEDGER_STANDALONE = "minimum_txn_in_ledger_standalone"; + static constexpr auto kNORMAL_CONSENSUS_INCREASE_PERCENT = "normal_consensus_increase_percent"; + static constexpr auto kNUDB_BLOCK_SIZE = "nudb_block_size"; + static constexpr auto kONLINE_DELETE = "online_delete"; + static constexpr auto kOPEN_FILES = "open_files"; + static constexpr auto kOPTIONS = "options"; + static constexpr auto kOVERLAY = "overlay"; + static constexpr auto kOWNER_RESERVE = "owner_reserve"; + static constexpr auto kPAGE_SIZE = "page_size"; + static constexpr auto kPASSWORD = "password"; + static constexpr auto kPATH = "path"; + static constexpr auto kPERMESSAGE_DEFLATE = "permessage_deflate"; + static constexpr auto kPORT = "port"; + static constexpr auto kPREFIX = "prefix"; + static constexpr auto kPROTOCOL = "protocol"; + static constexpr auto kRECOVERY_WAIT_SECONDS = "recovery_wait_seconds"; + static constexpr auto kREFERENCE_FEE = "reference_fee"; + static constexpr auto kRELAY_TIME = "relay_time"; + static constexpr auto kRETRY_SEQUENCE_PERCENT = "retry_sequence_percent"; + static constexpr auto kRQ_BUNDLE = "rq_bundle"; + static constexpr auto kSAFETY_LEVEL = "safety_level"; + static constexpr auto kSECURE_GATEWAY = "secureGateway"; + static constexpr auto kSEND_QUEUE_LIMIT = "send_queue_limit"; + static constexpr auto kSERVER = "server"; + static constexpr auto kSERVER_MAX_WINDOW_BITS = "server_max_window_bits"; + static constexpr auto kSERVER_NO_CONTEXT_TAKEOVER = "server_no_context_takeover"; + static constexpr auto kSSL_CERT = "ssl_cert"; + static constexpr auto kSSL_CERT_CHAIN = "ssl_cert_chain"; + static constexpr auto kSSL_CHAIN = "ssl_chain"; + static constexpr auto kSSL_CIPHERS = "ssl_ciphers"; + static constexpr auto kSSL_CLIENT_CA = "ssl_client_ca"; + static constexpr auto kSSL_KEY = "ssl_key"; + static constexpr auto kSYNCHRONOUS = "synchronous"; + static constexpr auto kTARGET_TXN_IN_LEDGER = "target_txn_in_ledger"; + static constexpr auto kTEMP_STORE = "temp_store"; + static constexpr auto kTX_ENABLE = "tx_enable"; + static constexpr auto kTX_METRICS = "tx_metrics"; + static constexpr auto kTX_MIN_PEERS = "tx_min_peers"; + static constexpr auto kTX_RELAY_PERCENTAGE = "tx_relay_percentage"; + static constexpr auto kTYPE = "type"; + static constexpr auto kUNIVERSAL_COMPACTION = "universal_compaction"; + static constexpr auto kUNL = "unl"; + static constexpr auto kUSE_TX_TABLES = "use_tx_tables"; + static constexpr auto kUSER = "user"; + static constexpr auto kVP_BASE_SQUELCH_ENABLE = "vp_base_squelch_enable"; + static constexpr auto kVP_BASE_SQUELCH_MAX_SELECTED_PEERS = + "vp_base_squelch_max_selected_peers"; + static constexpr auto kVP_ENABLE = "vp_enable"; +}; } // namespace xrpl diff --git a/src/libxrpl/nodestore/Database.cpp b/src/libxrpl/nodestore/Database.cpp index 2d7266bedc..81cf708468 100644 --- a/src/libxrpl/nodestore/Database.cpp +++ b/src/libxrpl/nodestore/Database.cpp @@ -38,8 +38,8 @@ Database::Database( beast::Journal journal) : j_(journal) , scheduler_(scheduler) - , earliestLedgerSeq_(get(config, kKEY_EARLIEST_SEQ, kXRP_LEDGER_EARLIEST_SEQ)) - , requestBundle_(get(config, kKEY_RQ_BUNDLE, 4)) + , earliestLedgerSeq_(get(config, Keys::kEARLIEST_SEQ, kXRP_LEDGER_EARLIEST_SEQ)) + , requestBundle_(get(config, Keys::kRQ_BUNDLE, 4)) , readThreads_(std::max(1, readThreads)) { XRPL_ASSERT(readThreads, "xrpl::NodeStore::Database::Database : nonzero threads input"); diff --git a/src/libxrpl/nodestore/ManagerImp.cpp b/src/libxrpl/nodestore/ManagerImp.cpp index 1a8bf1c8d9..4aac675d96 100644 --- a/src/libxrpl/nodestore/ManagerImp.cpp +++ b/src/libxrpl/nodestore/ManagerImp.cpp @@ -66,7 +66,7 @@ ManagerImp::makeBackend( Scheduler& scheduler, beast::Journal journal) { - std::string const type{get(parameters, kKEY_TYPE)}; + std::string const type{get(parameters, Keys::kTYPE)}; if (type.empty()) missingBackend(); diff --git a/src/libxrpl/nodestore/backend/MemoryFactory.cpp b/src/libxrpl/nodestore/backend/MemoryFactory.cpp index f3beef095c..42d6a10373 100644 --- a/src/libxrpl/nodestore/backend/MemoryFactory.cpp +++ b/src/libxrpl/nodestore/backend/MemoryFactory.cpp @@ -91,7 +91,7 @@ private: public: MemoryBackend(size_t keyBytes, Section const& keyValues, beast::Journal journal) - : name_(get(keyValues, kKEY_PATH)), journal_(journal) + : name_(get(keyValues, Keys::kPATH)), journal_(journal) { boost::ignore_unused(journal_); // Keep unused journal_ just in case. if (name_.empty()) diff --git a/src/libxrpl/nodestore/backend/NuDBFactory.cpp b/src/libxrpl/nodestore/backend/NuDBFactory.cpp index f58c37fa2c..f802b80105 100644 --- a/src/libxrpl/nodestore/backend/NuDBFactory.cpp +++ b/src/libxrpl/nodestore/backend/NuDBFactory.cpp @@ -73,7 +73,7 @@ public: : j(journal) , keyBytes(keyBytes) , burstSize(burstSize) - , name(get(keyValues, kKEY_PATH)) + , name(get(keyValues, Keys::kPATH)) , blockSize(parseBlockSize(name, keyValues, journal)) , deletePath(false) , scheduler(scheduler) @@ -92,7 +92,7 @@ public: : j(journal) , keyBytes(keyBytes) , burstSize(burstSize) - , name(get(keyValues, kKEY_PATH)) + , name(get(keyValues, Keys::kPATH)) , blockSize(parseBlockSize(name, keyValues, journal)) , db(context) , deletePath(false) @@ -382,7 +382,7 @@ private: std::size_t const blockSize = defaultSize; std::string blockSizeStr; - if (!getIfExists(keyValues, kKEY_NUDB_BLOCK_SIZE, blockSizeStr)) + if (!getIfExists(keyValues, Keys::kNUDB_BLOCK_SIZE, blockSizeStr)) { return blockSize; // Early return with default } diff --git a/src/libxrpl/nodestore/backend/RocksDBFactory.cpp b/src/libxrpl/nodestore/backend/RocksDBFactory.cpp index 041699d624..47761a539e 100644 --- a/src/libxrpl/nodestore/backend/RocksDBFactory.cpp +++ b/src/libxrpl/nodestore/backend/RocksDBFactory.cpp @@ -113,17 +113,18 @@ public: RocksDBEnv* env) : deletePath_(false), journal(journal), keyBytes(keyBytes), batch(*this, scheduler) { - if (!getIfExists(keyValues, kKEY_PATH, name)) + if (!getIfExists(keyValues, Keys::kPATH, name)) Throw("Missing path in RocksDBFactory backend"); rocksdb::BlockBasedTableOptions tableOptions; options.env = env; - bool const hardSet = keyValues.exists(kKEY_HARD_SET) && get(keyValues, kKEY_HARD_SET); + bool const hardSet = + keyValues.exists(Keys::kHARD_SET) && get(keyValues, Keys::kHARD_SET); - if (keyValues.exists(kKEY_CACHE_MB)) + if (keyValues.exists(Keys::kCACHE_MB)) { - auto size = get(keyValues, kKEY_CACHE_MB); + auto size = get(keyValues, Keys::kCACHE_MB); if (!hardSet && size == 256) size = 1024; @@ -131,14 +132,14 @@ public: tableOptions.block_cache = rocksdb::NewLRUCache(megabytes(size)); } - if (auto const v = get(keyValues, kKEY_FILTER_BITS)) + if (auto const v = get(keyValues, Keys::kFILTER_BITS)) { - bool const filterBlocks = - !keyValues.exists(kKEY_FILTER_FULL) || (get(keyValues, kKEY_FILTER_FULL) == 0); + bool const filterBlocks = !keyValues.exists(Keys::kFILTER_FULL) || + (get(keyValues, Keys::kFILTER_FULL) == 0); tableOptions.filter_policy.reset(rocksdb::NewBloomFilterPolicy(v, filterBlocks)); } - if (getIfExists(keyValues, kKEY_OPEN_FILES, options.max_open_files)) + if (getIfExists(keyValues, Keys::kOPEN_FILES, options.max_open_files)) { if (!hardSet && options.max_open_files == 2000) options.max_open_files = 8000; @@ -146,9 +147,9 @@ public: fdMinRequired = options.max_open_files + 128; } - if (keyValues.exists(kKEY_FILE_SIZE_MB)) + if (keyValues.exists(Keys::kFILE_SIZE_MB)) { - auto fileSizeMb = get(keyValues, kKEY_FILE_SIZE_MB); + auto fileSizeMb = get(keyValues, Keys::kFILE_SIZE_MB); if (!hardSet && fileSizeMb == 8) fileSizeMb = 256; @@ -158,17 +159,17 @@ public: options.write_buffer_size = 2 * options.target_file_size_base; } - getIfExists(keyValues, kKEY_FILE_SIZE_MULT, options.target_file_size_multiplier); + getIfExists(keyValues, Keys::kFILE_SIZE_MULT, options.target_file_size_multiplier); - if (keyValues.exists(kKEY_BG_THREADS)) + if (keyValues.exists(Keys::kBG_THREADS)) { options.env->SetBackgroundThreads( - get(keyValues, kKEY_BG_THREADS), rocksdb::Env::LOW); + get(keyValues, Keys::kBG_THREADS), rocksdb::Env::LOW); } - if (keyValues.exists(kKEY_HIGH_THREADS)) + if (keyValues.exists(Keys::kHIGH_THREADS)) { - auto const highThreads = get(keyValues, kKEY_HIGH_THREADS); + auto const highThreads = get(keyValues, Keys::kHIGH_THREADS); options.env->SetBackgroundThreads(highThreads, rocksdb::Env::HIGH); // If we have high-priority threads, presumably we want to @@ -179,10 +180,10 @@ public: options.compression = rocksdb::kSnappyCompression; - getIfExists(keyValues, kKEY_BLOCK_SIZE, tableOptions.block_size); + getIfExists(keyValues, Keys::kBLOCK_SIZE, tableOptions.block_size); - if (keyValues.exists(kKEY_UNIVERSAL_COMPACTION) && - (get(keyValues, kKEY_UNIVERSAL_COMPACTION) != 0)) + if (keyValues.exists(Keys::kUNIVERSAL_COMPACTION) && + (get(keyValues, Keys::kUNIVERSAL_COMPACTION) != 0)) { options.compaction_style = rocksdb::kCompactionStyleUniversal; options.min_write_buffer_number_to_merge = 2; @@ -190,11 +191,11 @@ public: options.write_buffer_size = 6 * options.target_file_size_base; } - if (keyValues.exists(kKEY_BBT_OPTIONS)) + if (keyValues.exists(Keys::kBBT_OPTIONS)) { rocksdb::ConfigOptions const configOptions; auto const s = rocksdb::GetBlockBasedTableOptionsFromString( - configOptions, tableOptions, get(keyValues, kKEY_BBT_OPTIONS), &tableOptions); + configOptions, tableOptions, get(keyValues, Keys::kBBT_OPTIONS), &tableOptions); if (!s.ok()) { Throw( @@ -204,10 +205,10 @@ public: options.table_factory.reset(NewBlockBasedTableFactory(tableOptions)); - if (keyValues.exists(kKEY_OPTIONS)) + if (keyValues.exists(Keys::kOPTIONS)) { auto const s = - rocksdb::GetOptionsFromString(options, get(keyValues, kKEY_OPTIONS), &options); + rocksdb::GetOptionsFromString(options, get(keyValues, Keys::kOPTIONS), &options); if (!s.ok()) { Throw( diff --git a/src/libxrpl/rdb/SociDB.cpp b/src/libxrpl/rdb/SociDB.cpp index a27d004eec..0e3ffaa64a 100644 --- a/src/libxrpl/rdb/SociDB.cpp +++ b/src/libxrpl/rdb/SociDB.cpp @@ -53,13 +53,13 @@ getSociSqliteInit(std::string const& name, std::string const& dir, std::string c std::string getSociInit(BasicConfig const& config, std::string const& dbName) { - auto const& section = config.section(kSECTION_SQDB); - auto const backendName = get(section, kKEY_BACKEND, "sqlite"); + auto const& section = config.section(Sections::kSQDB); + auto const backendName = get(section, Keys::kBACKEND, "sqlite"); if (backendName != "sqlite") Throw("Unsupported soci backend: " + backendName); - auto const path = config.legacy(kSECTION_DATABASE_PATH); + auto const path = config.legacy(Sections::kDATABASE_PATH); auto const ext = dbName == "validators" || dbName == "peerfinder" ? ".sqlite" : ".db"; return detail::getSociSqliteInit(dbName, path, ext); } diff --git a/src/libxrpl/server/Port.cpp b/src/libxrpl/server/Port.cpp index 51d2eb04d1..368264703e 100644 --- a/src/libxrpl/server/Port.cpp +++ b/src/libxrpl/server/Port.cpp @@ -195,7 +195,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log) { port.name = section.name(); { - auto const optResult = section.get(kKEY_IP); + auto const optResult = section.get(Keys::kIP); if (optResult) { try @@ -212,7 +212,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log) } { - auto const optResult = section.get(kKEY_PORT); + auto const optResult = section.get(Keys::kPORT); if (optResult) { try @@ -233,7 +233,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log) } { - auto const optResult = section.get(kKEY_PROTOCOL); + auto const optResult = section.get(Keys::kPROTOCOL); if (optResult) { for (auto const& s : beast::rfc2616::splitCommas(optResult->begin(), optResult->end())) @@ -242,7 +242,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log) } { - auto const lim = get(section, kKEY_LIMIT, "unlimited"); + auto const lim = get(section, Keys::kLIMIT, "unlimited"); if (!boost::iequals(lim, "unlimited")) { @@ -260,7 +260,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log) } { - auto const optResult = section.get(kKEY_SEND_QUEUE_LIMIT); + auto const optResult = section.get(Keys::kSEND_QUEUE_LIMIT); if (optResult) { try @@ -285,32 +285,32 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log) } } - populate(section, kKEY_ADMIN, log, port.admin_nets_v4, port.admin_nets_v6); + populate(section, Keys::kADMIN, log, port.admin_nets_v4, port.admin_nets_v6); populate( section, - kKEY_SECURE_GATEWAY, + Keys::kSECURE_GATEWAY, log, port.secure_gateway_nets_v4, port.secure_gateway_nets_v6); - set(port.user, kKEY_USER, section); - set(port.password, kKEY_PASSWORD, section); - set(port.admin_user, kKEY_ADMIN_USER, section); - set(port.admin_password, kKEY_ADMIN_PASSWORD, section); - set(port.ssl_key, kKEY_SSL_KEY, section); - set(port.ssl_cert, kKEY_SSL_CERT, section); - set(port.ssl_chain, kKEY_SSL_CHAIN, section); - set(port.ssl_ciphers, kKEY_SSL_CIPHERS, section); + set(port.user, Keys::kUSER, section); + set(port.password, Keys::kPASSWORD, section); + set(port.admin_user, Keys::kADMIN_USER, section); + set(port.admin_password, Keys::kADMIN_PASSWORD, section); + set(port.ssl_key, Keys::kSSL_KEY, section); + set(port.ssl_cert, Keys::kSSL_CERT, section); + set(port.ssl_chain, Keys::kSSL_CHAIN, section); + set(port.ssl_ciphers, Keys::kSSL_CIPHERS, section); - port.pmd_options.server_enable = section.valueOr(kKEY_PERMESSAGE_DEFLATE, true); - port.pmd_options.client_max_window_bits = section.valueOr(kKEY_CLIENT_MAX_WINDOW_BITS, 15); - port.pmd_options.server_max_window_bits = section.valueOr(kKEY_SERVER_MAX_WINDOW_BITS, 15); + port.pmd_options.server_enable = section.valueOr(Keys::kPERMESSAGE_DEFLATE, true); + port.pmd_options.client_max_window_bits = section.valueOr(Keys::kCLIENT_MAX_WINDOW_BITS, 15); + port.pmd_options.server_max_window_bits = section.valueOr(Keys::kSERVER_MAX_WINDOW_BITS, 15); port.pmd_options.client_no_context_takeover = - section.valueOr(kKEY_CLIENT_NO_CONTEXT_TAKEOVER, false); + section.valueOr(Keys::kCLIENT_NO_CONTEXT_TAKEOVER, false); port.pmd_options.server_no_context_takeover = - section.valueOr(kKEY_SERVER_NO_CONTEXT_TAKEOVER, false); - port.pmd_options.compLevel = section.valueOr(kKEY_COMPRESS_LEVEL, 8); - port.pmd_options.memLevel = section.valueOr(kKEY_MEMORY_LEVEL, 4); + section.valueOr(Keys::kSERVER_NO_CONTEXT_TAKEOVER, false); + port.pmd_options.compLevel = section.valueOr(Keys::kCOMPRESS_LEVEL, 8); + port.pmd_options.memLevel = section.valueOr(Keys::kMEMORY_LEVEL, 4); } } // namespace xrpl diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 8621884426..96a726d4f5 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -82,8 +82,8 @@ private: makeConfig() { auto cfg = test::jtx::envconfig(); - cfg->section(kSECTION_AMENDMENTS) = makeSection(kSECTION_AMENDMENTS, enabled_); - cfg->section(kSECTION_VETO_AMENDMENTS) = makeSection(kSECTION_VETO_AMENDMENTS, vetoed_); + cfg->section(Sections::kAMENDMENTS) = makeSection(Sections::kAMENDMENTS, enabled_); + cfg->section(Sections::kVETO_AMENDMENTS) = makeSection(Sections::kVETO_AMENDMENTS, vetoed_); return cfg; } diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index bf430a7980..30b6f9bb0d 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -169,13 +169,13 @@ class Batch_test : public beast::unit_test::Suite std::map extraVoting = {}) { auto p = test::jtx::envconfig(); - auto& section = p->section(kSECTION_TRANSACTION_QUEUE); - section.set(kKEY_LEDGERS_IN_QUEUE, "2"); - section.set(kKEY_MINIMUM_QUEUE_SIZE, "2"); - section.set(kKEY_MIN_LEDGERS_TO_COMPUTE_SIZE_LIMIT, "3"); - section.set(kKEY_MAX_LEDGER_COUNTS_TO_STORE, "100"); - section.set(kKEY_RETRY_SEQUENCE_PERCENT, "25"); - section.set(kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT, "0"); + auto& section = p->section(Sections::kTRANSACTION_QUEUE); + section.set(Keys::kLEDGERS_IN_QUEUE, "2"); + section.set(Keys::kMINIMUM_QUEUE_SIZE, "2"); + section.set(Keys::kMIN_LEDGERS_TO_COMPUTE_SIZE_LIMIT, "3"); + section.set(Keys::kMAX_LEDGER_COUNTS_TO_STORE, "100"); + section.set(Keys::kRETRY_SEQUENCE_PERCENT, "25"); + section.set(Keys::kNORMAL_CONSENSUS_INCREASE_PERCENT, "0"); for (auto const& [k, v] : extraTxQ) section.set(k, v); @@ -3782,7 +3782,7 @@ class Batch_test : public beast::unit_test::Suite { test::jtx::Env env{ *this, - makeSmallQueueConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}}), + makeSmallQueueConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}}), features, nullptr, beast::severities::KError}; @@ -3838,7 +3838,7 @@ class Batch_test : public beast::unit_test::Suite { test::jtx::Env env{ *this, - makeSmallQueueConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}}), + makeSmallQueueConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}}), features, nullptr, beast::severities::KError}; diff --git a/src/test/app/GRPCServerTLS_test.cpp b/src/test/app/GRPCServerTLS_test.cpp index 9b0b6c76c8..650eccb3fe 100644 --- a/src/test/app/GRPCServerTLS_test.cpp +++ b/src/test/app/GRPCServerTLS_test.cpp @@ -367,7 +367,8 @@ public: Env env(*this, std::move(cfg)); // Verify the server actually started by checking the port - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); // NOLINTBEGIN(bugprone-unchecked-optional-access) grpcPort.has_value() checked above BEAST_EXPECT(*grpcPort > 0); @@ -393,7 +394,8 @@ public: Env env(*this, std::move(cfg)); // Verify the server actually started by checking the port - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); // NOLINTBEGIN(bugprone-unchecked-optional-access) grpcPort.has_value() checked above BEAST_EXPECT(*grpcPort > 0); @@ -430,7 +432,8 @@ public: Env env(*this, std::move(cfg)); // Verify the server actually started by checking the port - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); // NOLINTBEGIN(bugprone-unchecked-optional-access) grpcPort.has_value() checked above BEAST_EXPECT(*grpcPort > 0); @@ -464,9 +467,9 @@ public: // Create config with only cert (missing key) auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); // Intentionally omit ssl_key try @@ -490,9 +493,9 @@ public: // Create config with only key (missing cert) auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); // Intentionally omit ssl_cert try @@ -517,9 +520,9 @@ public: // Test 1: ssl_client_ca specified without any TLS config { auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, getCACertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, getCACertPath().string()); // Intentionally omit both ssl_cert and ssl_key try @@ -538,10 +541,10 @@ public: // Test 2: ssl_client_ca with only ssl_cert (missing ssl_key) { auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, getCACertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, getCACertPath().string()); // Intentionally omit ssl_key try @@ -562,10 +565,10 @@ public: // Test 3: ssl_client_ca with only ssl_key (missing ssl_cert) { auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, getCACertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, getCACertPath().string()); // Intentionally omit ssl_cert try @@ -594,9 +597,9 @@ public: // Test 1: ssl_cert_chain specified without any TLS config { auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT_CHAIN, getCACertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT_CHAIN, getCACertPath().string()); // Intentionally omit both ssl_cert and ssl_key try @@ -615,10 +618,10 @@ public: // Test 2: ssl_cert_chain with only ssl_cert (missing ssl_key) { auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT_CHAIN, getCACertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT_CHAIN, getCACertPath().string()); // Intentionally omit ssl_key try @@ -654,7 +657,8 @@ public: Env env(*this, std::move(cfg)); // Verify the server actually started by checking the port - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); // NOLINTBEGIN(bugprone-unchecked-optional-access) grpcPort.has_value() checked above BEAST_EXPECT(*grpcPort > 0); @@ -683,15 +687,16 @@ public: using namespace jtx; auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, "/nonexistent/path/to/cert.pem"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, "/nonexistent/path/to/cert.pem"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); Env env(*this, std::move(cfg)); // Server should fail to start - verify port is 0 - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); BEAST_EXPECT(*grpcPort == 0); // NOLINT(bugprone-unchecked-optional-access) } @@ -704,15 +709,16 @@ public: using namespace jtx; auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, "/nonexistent/path/to/key.pem"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, "/nonexistent/path/to/key.pem"); Env env(*this, std::move(cfg)); // Server should fail to start - verify port is 0 - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); BEAST_EXPECT(*grpcPort == 0); // NOLINT(bugprone-unchecked-optional-access) } @@ -725,16 +731,17 @@ public: using namespace jtx; auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT_CHAIN, "/nonexistent/path/to/chain.pem"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT_CHAIN, "/nonexistent/path/to/chain.pem"); Env env(*this, std::move(cfg)); // Server should fail to start - verify port is 0 - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); BEAST_EXPECT(*grpcPort == 0); // NOLINT(bugprone-unchecked-optional-access) } @@ -747,16 +754,17 @@ public: using namespace jtx; auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, "/nonexistent/path/to/ca.pem"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, "/nonexistent/path/to/ca.pem"); Env env(*this, std::move(cfg)); // Server should fail to start - verify port is 0 - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); BEAST_EXPECT(*grpcPort == 0); // NOLINT(bugprone-unchecked-optional-access) } @@ -774,16 +782,17 @@ public: emptyFile.close(); auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, "127.0.0.1"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, emptyCAPath.string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, "127.0.0.1"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, emptyCAPath.string()); Env env(*this, std::move(cfg)); // Server should fail to start due to empty CA file - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); BEAST_EXPECT(*grpcPort == 0); // NOLINT(bugprone-unchecked-optional-access) } @@ -797,18 +806,19 @@ public: // Test with all TLS features enabled: cert, key, cert_chain, and client_ca auto cfg = envconfig(); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, getServerCertPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, getServerKeyPath().string()); - (*cfg)[kSECTION_PORT_GRPC].set( + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, getServerCertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, getServerKeyPath().string()); + (*cfg)[Sections::kPORT_GRPC].set( "ssl_cert_chain", getCACertPath().string()); // Using CA as intermediate - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, getCACertPath().string()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, getCACertPath().string()); Env env(*this, std::move(cfg)); // Verify the server started successfully - auto const grpcPort = env.app().config()[kSECTION_PORT_GRPC].get(kKEY_PORT); + auto const grpcPort = + env.app().config()[Sections::kPORT_GRPC].get(Keys::kPORT); BEAST_EXPECT(grpcPort.has_value()); // NOLINTBEGIN(bugprone-unchecked-optional-access) grpcPort.has_value() checked above BEAST_EXPECT(*grpcPort > 0); diff --git a/src/test/app/HashRouter_test.cpp b/src/test/app/HashRouter_test.cpp index bae002b53e..bf5281238c 100644 --- a/src/test/app/HashRouter_test.cpp +++ b/src/test/app/HashRouter_test.cpp @@ -275,9 +275,9 @@ class HashRouter_test : public beast::unit_test::Suite { Config cfg; // non-default - auto& h = cfg.section(kSECTION_HASHROUTER); - h.set(kKEY_HOLD_TIME, "600"); - h.set(kKEY_RELAY_TIME, "15"); + auto& h = cfg.section(Sections::kHASHROUTER); + h.set(Keys::kHOLD_TIME, "600"); + h.set(Keys::kRELAY_TIME, "15"); auto const setup = setupHashRouter(cfg); BEAST_EXPECT(setup.holdTime == 600s); BEAST_EXPECT(setup.relayTime == 15s); @@ -285,9 +285,9 @@ class HashRouter_test : public beast::unit_test::Suite { Config cfg; // equal - auto& h = cfg.section(kSECTION_HASHROUTER); - h.set(kKEY_HOLD_TIME, "400"); - h.set(kKEY_RELAY_TIME, "400"); + auto& h = cfg.section(Sections::kHASHROUTER); + h.set(Keys::kHOLD_TIME, "400"); + h.set(Keys::kRELAY_TIME, "400"); auto const setup = setupHashRouter(cfg); BEAST_EXPECT(setup.holdTime == 400s); BEAST_EXPECT(setup.relayTime == 400s); @@ -295,9 +295,9 @@ class HashRouter_test : public beast::unit_test::Suite { Config cfg; // wrong order - auto& h = cfg.section(kSECTION_HASHROUTER); - h.set(kKEY_HOLD_TIME, "60"); - h.set(kKEY_RELAY_TIME, "120"); + auto& h = cfg.section(Sections::kHASHROUTER); + h.set(Keys::kHOLD_TIME, "60"); + h.set(Keys::kRELAY_TIME, "120"); try { setupHashRouter(cfg); @@ -314,9 +314,9 @@ class HashRouter_test : public beast::unit_test::Suite { Config cfg; // too small hold - auto& h = cfg.section(kSECTION_HASHROUTER); - h.set(kKEY_HOLD_TIME, "10"); - h.set(kKEY_RELAY_TIME, "120"); + auto& h = cfg.section(Sections::kHASHROUTER); + h.set(Keys::kHOLD_TIME, "10"); + h.set(Keys::kRELAY_TIME, "120"); try { setupHashRouter(cfg); @@ -334,9 +334,9 @@ class HashRouter_test : public beast::unit_test::Suite { Config cfg; // too small relay - auto& h = cfg.section(kSECTION_HASHROUTER); - h.set(kKEY_HOLD_TIME, "500"); - h.set(kKEY_RELAY_TIME, "6"); + auto& h = cfg.section(Sections::kHASHROUTER); + h.set(Keys::kHOLD_TIME, "500"); + h.set(Keys::kRELAY_TIME, "6"); try { setupHashRouter(cfg); @@ -353,9 +353,9 @@ class HashRouter_test : public beast::unit_test::Suite { Config cfg; // garbage - auto& h = cfg.section(kSECTION_HASHROUTER); - h.set(kKEY_HOLD_TIME, "alice"); - h.set(kKEY_RELAY_TIME, "bob"); + auto& h = cfg.section(Sections::kHASHROUTER); + h.set(Keys::kHOLD_TIME, "alice"); + h.set(Keys::kRELAY_TIME, "bob"); auto const setup = setupHashRouter(cfg); // The set function ignores values that don't convert, so the // defaults are left unchanged diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index fae82e96c4..03302465f9 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -247,7 +247,7 @@ public: auto& app = env.app(); auto unl = std::make_unique( - m, m, env.timeKeeper(), app.config().legacy(kSECTION_DATABASE_PATH), env.journal); + m, m, env.timeKeeper(), app.config().legacy(Sections::kDATABASE_PATH), env.journal); { // save should not store untrusted master keys to db diff --git a/src/test/app/MultiSign_test.cpp b/src/test/app/MultiSign_test.cpp index 1a6365afa2..5b75cb7b99 100644 --- a/src/test/app/MultiSign_test.cpp +++ b/src/test/app/MultiSign_test.cpp @@ -496,7 +496,7 @@ public: Env env( *this, envconfig([](std::unique_ptr cfg) { - cfg->loadFromString(std::string("[") + kSECTION_SIGNING_SUPPORT + "]\ntrue"); + cfg->loadFromString(std::string("[") + Sections::kSIGNING_SUPPORT + "]\ntrue"); return cfg; }), features); @@ -1308,7 +1308,7 @@ public: Env env( *this, envconfig([](std::unique_ptr cfg) { - cfg->loadFromString(std::string("[") + kSECTION_SIGNING_SUPPORT + "]\ntrue"); + cfg->loadFromString(std::string("[") + Sections::kSIGNING_SUPPORT + "]\ntrue"); return cfg; }), features); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index 630793d7ee..3b24c9d41a 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -194,8 +194,8 @@ struct Regression_test : public beast::unit_test::Suite testcase("Autofilled fee should use the escalated fee"); using namespace jtx; Env env(*this, envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_TRANSACTION_QUEUE) - .set(kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); + cfg->section(Sections::kTRANSACTION_QUEUE) + .set(Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); cfg->FEES.reference_fee = 10; return cfg; })); @@ -235,11 +235,11 @@ struct Regression_test : public beast::unit_test::Suite using namespace std::chrono_literals; Env env(*this, envconfig([](std::unique_ptr cfg) { - auto& s = cfg->section(kSECTION_TRANSACTION_QUEUE); - s.set(kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "4294967295"); - s.set(kKEY_MINIMUM_TXN_IN_LEDGER, "4294967295"); - s.set(kKEY_TARGET_TXN_IN_LEDGER, "4294967295"); - s.set(kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT, "4294967295"); + auto& s = cfg->section(Sections::kTRANSACTION_QUEUE); + s.set(Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "4294967295"); + s.set(Keys::kMINIMUM_TXN_IN_LEDGER, "4294967295"); + s.set(Keys::kTARGET_TXN_IN_LEDGER, "4294967295"); + s.set(Keys::kNORMAL_CONSENSUS_INCREASE_PERCENT, "4294967295"); return cfg; })); diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index d3dddae953..763cb96a99 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -42,8 +42,8 @@ class SHAMapStore_test : public beast::unit_test::Suite onlineDelete(std::unique_ptr cfg) { cfg->LEDGER_HISTORY = kDELETE_INTERVAL; - auto& section = cfg->section(kSECTION_NODE_DATABASE); - section.set(kKEY_ONLINE_DELETE, std::to_string(kDELETE_INTERVAL)); + auto& section = cfg->section(Sections::kNODE_DATABASE); + section.set(Keys::kONLINE_DELETE, std::to_string(kDELETE_INTERVAL)); return cfg; } @@ -51,7 +51,7 @@ class SHAMapStore_test : public beast::unit_test::Suite advisoryDelete(std::unique_ptr cfg) { cfg = onlineDelete(std::move(cfg)); - cfg->section(kSECTION_NODE_DATABASE).set(kKEY_ADVISORY_DELETE, "1"); + cfg->section(Sections::kNODE_DATABASE).set(Keys::kADVISORY_DELETE, "1"); return cfg; } @@ -490,13 +490,13 @@ public: std::unique_ptr makeBackendRotating(jtx::Env& env, NodeStoreScheduler& scheduler, std::string path) { - Section section{env.app().config().section(kSECTION_NODE_DATABASE)}; + Section section{env.app().config().section(Sections::kNODE_DATABASE)}; boost::filesystem::path newPath; if (!BEAST_EXPECT(path.size())) return {}; newPath = path; - section.set(kKEY_PATH, newPath.string()); + section.set(Keys::kPATH, newPath.string()); auto backend{NodeStore::Manager::instance().makeBackend( section, @@ -528,7 +528,7 @@ public: auto archiveBackend = makeBackendRotating(env, scheduler, archiveDb); constexpr int kREAD_THREADS = 4; - auto nscfg = env.app().config().section(kSECTION_NODE_DATABASE); + auto nscfg = env.app().config().section(Sections::kNODE_DATABASE); auto dbr = std::make_unique( scheduler, kREAD_THREADS, diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index b03141f884..ecc4c6ea6f 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -168,7 +168,7 @@ public: using namespace std::chrono; testcase("queue sequence"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto alice = Account("alice"); auto bob = Account("bob"); @@ -381,7 +381,7 @@ public: using namespace jtx; testcase("queue ticket"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto alice = Account("alice"); @@ -619,7 +619,7 @@ public: using namespace jtx; testcase("queue tec"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); auto alice = Account("alice"); auto gw = Account("gw"); @@ -656,7 +656,7 @@ public: using namespace std::chrono; testcase("local tx retry"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); auto alice = Account("alice"); auto bob = Account("bob"); @@ -709,7 +709,7 @@ public: using namespace std::chrono; testcase("last ledger sequence"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); auto alice = Account("alice"); auto bob = Account("bob"); @@ -832,7 +832,7 @@ public: using namespace std::chrono; testcase("zero transaction fee"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); auto alice = Account("alice"); auto bob = Account("bob"); @@ -959,7 +959,7 @@ public: using namespace jtx; testcase("queued tx fails"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}})); auto alice = Account("alice"); auto bob = Account("bob"); @@ -1011,7 +1011,7 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, {{"account_reserve", "200"}, {"owner_reserve", "50"}})); auto alice = Account("alice"); @@ -1255,7 +1255,7 @@ public: using namespace std::chrono; testcase("tie breaking"); - auto cfg = makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "4"}}); + auto cfg = makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "4"}}); cfg->FEES.reference_fee = 10; Env env(*this, std::move(cfg)); @@ -1468,7 +1468,7 @@ public: using namespace jtx; testcase("acct tx id"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}})); auto alice = Account("alice"); @@ -1508,9 +1508,9 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}, - {kKEY_MINIMUM_TXN_IN_LEDGER, "5"}, - {kKEY_TARGET_TXN_IN_LEDGER, "4"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}, + {Keys::kMINIMUM_TXN_IN_LEDGER, "5"}, + {Keys::kTARGET_TXN_IN_LEDGER, "4"}, {"maximum_txn_in_ledger", "5"}})); auto const baseFee = env.current()->fees().base.drops(); @@ -1552,9 +1552,9 @@ public: Env const env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER, "200"}, - {kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "200"}, - {kKEY_TARGET_TXN_IN_LEDGER, "4"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER, "200"}, + {Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "200"}, + {Keys::kTARGET_TXN_IN_LEDGER, "4"}, {"maximum_txn_in_ledger", "5"}})); // should throw fail(); @@ -1573,9 +1573,9 @@ public: Env const env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER, "200"}, - {kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}, - {kKEY_TARGET_TXN_IN_LEDGER, "4"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER, "200"}, + {Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "2"}, + {Keys::kTARGET_TXN_IN_LEDGER, "4"}, {"maximum_txn_in_ledger", "5"}})); // should throw fail(); @@ -1594,9 +1594,9 @@ public: Env const env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER, "2"}, - {kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "200"}, - {kKEY_TARGET_TXN_IN_LEDGER, "4"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER, "2"}, + {Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "200"}, + {Keys::kTARGET_TXN_IN_LEDGER, "4"}, {"maximum_txn_in_ledger", "5"}})); // should throw fail(); @@ -1621,7 +1621,7 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, {{"account_reserve", "200"}, {"owner_reserve", "50"}})); auto alice = Account("alice"); @@ -1713,7 +1713,7 @@ public: auto queued = Ter(terQUEUED); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -1842,7 +1842,7 @@ public: auto queued = Ter(terQUEUED); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -1993,7 +1993,7 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, {{"account_reserve", "200"}, {"owner_reserve", "50"}})); auto alice = Account("alice"); @@ -2396,7 +2396,7 @@ public: auto queued = Ter(terQUEUED); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -2565,8 +2565,8 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}, - {kKEY_LEDGERS_IN_QUEUE, "10"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}, + {Keys::kLEDGERS_IN_QUEUE, "10"}, {"maximum_txn_per_account", "20"}})); auto const baseFee = env.current()->fees().base.drops(); @@ -2647,8 +2647,8 @@ public: testcase("full queue gap handling"); auto cfg = makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}, - {kKEY_LEDGERS_IN_QUEUE, "10"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}, + {Keys::kLEDGERS_IN_QUEUE, "10"}, {"maximum_txn_per_account", "11"}}); cfg->FEES.reference_fee = 10; Env env(*this, std::move(cfg)); @@ -2774,7 +2774,7 @@ public: { testcase("Autofilled sequence should account for TxQ"); using namespace jtx; - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "6"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "6"}})); auto const baseFee = env.current()->fees().base.drops(); EnvSs envs(env); auto const& txQ = env.app().getTxQ(); @@ -2908,7 +2908,7 @@ public: using namespace jtx; testcase("account info"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); EnvSs envs(env); @@ -3178,7 +3178,7 @@ public: using namespace jtx; testcase("server info"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); EnvSs envs(env); @@ -3404,7 +3404,7 @@ public: using namespace jtx; testcase("server subscribe"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); json::Value stream; @@ -3543,7 +3543,7 @@ public: using namespace jtx; testcase("clear queued acct txs"); - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const baseFee = env.current()->fees().base.drops(); auto alice = Account("alice"); auto bob = Account("bob"); @@ -3753,10 +3753,10 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}, - {kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT, "25"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}, + {Keys::kNORMAL_CONSENSUS_INCREASE_PERCENT, "25"}, {"slow_consensus_decrease_percent", "50"}, - {kKEY_TARGET_TXN_IN_LEDGER, "10"}, + {Keys::kTARGET_TXN_IN_LEDGER, "10"}, {"maximum_txn_per_account", "200"}})); auto alice = Account("alice"); @@ -3839,10 +3839,10 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}, - {kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT, "150"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}, + {Keys::kNORMAL_CONSENSUS_INCREASE_PERCENT, "150"}, {"slow_consensus_decrease_percent", "150"}, - {kKEY_TARGET_TXN_IN_LEDGER, "10"}, + {Keys::kTARGET_TXN_IN_LEDGER, "10"}, {"maximum_txn_per_account", "200"}})); auto alice = Account("alice"); @@ -3896,7 +3896,7 @@ public: testcase("Sequence in queue and open ledger"); using namespace jtx; - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto const alice = Account("alice"); @@ -3959,7 +3959,7 @@ public: testcase("Ticket in queue and open ledger"); using namespace jtx; - Env env(*this, makeConfig({{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); + Env env(*this, makeConfig({{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}})); auto alice = Account("alice"); @@ -4060,16 +4060,16 @@ public: constexpr int kLEDGERS_IN_QUEUE = 30; auto cfg = makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}, - {kKEY_LEDGERS_IN_QUEUE, std::to_string(kLEDGERS_IN_QUEUE)}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "1"}, + {Keys::kLEDGERS_IN_QUEUE, std::to_string(kLEDGERS_IN_QUEUE)}, {"maximum_txn_per_account", "10"}}, {{"account_reserve", "1000"}, {"owner_reserve", "50"}}); - auto& votingSection = cfg->section(kSECTION_VOTING); + auto& votingSection = cfg->section(Sections::kVOTING); votingSection.set( - kKEY_ACCOUNT_RESERVE, std::to_string(cfg->FEES.reference_fee.drops() * 100)); + Keys::kACCOUNT_RESERVE, std::to_string(cfg->FEES.reference_fee.drops() * 100)); - votingSection.set(kKEY_REFERENCE_FEE, std::to_string(cfg->FEES.reference_fee.drops())); + votingSection.set(Keys::kREFERENCE_FEE, std::to_string(cfg->FEES.reference_fee.drops())); Env env(*this, std::move(cfg)); @@ -4226,10 +4226,10 @@ public: Account const fiona("fiona"); auto cfg = makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "5"}, - {kKEY_LEDGERS_IN_QUEUE, "5"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "5"}, + {Keys::kLEDGERS_IN_QUEUE, "5"}, {"maximum_txn_per_account", "30"}, - {kKEY_MINIMUM_QUEUE_SIZE, "50"}}); + {Keys::kMINIMUM_QUEUE_SIZE, "50"}}); Env env(*this, std::move(cfg)); auto const baseFee = env.current()->fees().base.drops(); @@ -4435,10 +4435,10 @@ public: auto usd = gw["USD"]; auto cfg = makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "5"}, - {kKEY_LEDGERS_IN_QUEUE, "5"}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "5"}, + {Keys::kLEDGERS_IN_QUEUE, "5"}, {"maximum_txn_per_account", "30"}, - {kKEY_MINIMUM_QUEUE_SIZE, "50"}}); + {Keys::kMINIMUM_QUEUE_SIZE, "50"}}); Env env(*this, std::move(cfg)); @@ -4535,7 +4535,7 @@ public: Env env( *this, makeConfig( - {{kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, + {{Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"}}, {{"reference_fee", "0"}, {"account_reserve", "0"}, {"owner_reserve", "0"}})); checkMetrics(*this, env, 0, std::nullopt, 0, 3); diff --git a/src/test/app/ValidatorKeys_test.cpp b/src/test/app/ValidatorKeys_test.cpp index 777fc7b225..0a5b9106c9 100644 --- a/src/test/app/ValidatorKeys_test.cpp +++ b/src/test/app/ValidatorKeys_test.cpp @@ -100,7 +100,7 @@ public: { // validation seed section -> empty manifest and valid seeds Config c; - c.section(kSECTION_VALIDATION_SEED).append(seed_); + c.section(Sections::kVALIDATION_SEED).append(seed_); ValidatorKeys k{c, journal}; if (BEAST_EXPECT(k.keys); k.keys.has_value()) @@ -116,7 +116,7 @@ public: { // validation seed bad seed -> invalid Config c; - c.section(kSECTION_VALIDATION_SEED).append("badseed"); + c.section(Sections::kVALIDATION_SEED).append("badseed"); ValidatorKeys const k{c, journal}; BEAST_EXPECT(k.configInvalid()); @@ -127,7 +127,7 @@ public: { // validator token Config c; - c.section(kSECTION_VALIDATOR_TOKEN).append(tokenBlob_); + c.section(Sections::kVALIDATOR_TOKEN).append(tokenBlob_); ValidatorKeys k{c, journal}; if (BEAST_EXPECT(k.keys); k.keys.has_value()) @@ -142,7 +142,7 @@ public: { // invalid validator token Config c; - c.section(kSECTION_VALIDATOR_TOKEN).append("badtoken"); + c.section(Sections::kVALIDATOR_TOKEN).append("badtoken"); ValidatorKeys const k{c, journal}; BEAST_EXPECT(k.configInvalid()); BEAST_EXPECT(!k.keys); @@ -152,8 +152,8 @@ public: { // Cannot specify both Config c; - c.section(kSECTION_VALIDATION_SEED).append(seed_); - c.section(kSECTION_VALIDATOR_TOKEN).append(tokenBlob_); + c.section(Sections::kVALIDATION_SEED).append(seed_); + c.section(Sections::kVALIDATOR_TOKEN).append(tokenBlob_); ValidatorKeys const k{c, journal}; BEAST_EXPECT(k.configInvalid()); @@ -164,7 +164,7 @@ public: { // Token manifest and private key must match Config c; - c.section(kSECTION_VALIDATOR_TOKEN).append(invalidTokenBlob_); + c.section(Sections::kVALIDATOR_TOKEN).append(invalidTokenBlob_); ValidatorKeys const k{c, journal}; BEAST_EXPECT(k.configInvalid()); diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index d458f57215..e89da152d4 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -199,7 +199,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); BEAST_EXPECT(trustedKeys->quorum() == 1); } @@ -209,7 +209,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal, minQuorum); BEAST_EXPECT(trustedKeys->quorum() == minQuorum); @@ -267,7 +267,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); // Correct (empty) configuration @@ -293,7 +293,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); BEAST_EXPECT(trustedKeys->load({}, cfgKeys, emptyCfgPublishers)); @@ -328,7 +328,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const localSigningPublic = @@ -348,7 +348,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const localSigningPublic = randomNode(); @@ -366,7 +366,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) @@ -386,7 +386,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); // load should reject invalid validator list signing keys @@ -422,7 +422,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); std::vector const keys( @@ -447,7 +447,7 @@ private: valManifests, pubManifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const pubRevokedSecret = randomSecretKey(); @@ -486,7 +486,7 @@ private: valManifests, pubManifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const pubRevokedSecret = randomSecretKey(); @@ -572,7 +572,7 @@ private: manifests, manifests, env.app().getTimeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto expectTrusted = [this, &trustedKeys](std::vector const& list) { @@ -934,7 +934,7 @@ private: manifests, manifests, env.app().getTimeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const publisherSecret = randomSecretKey(); @@ -1065,7 +1065,7 @@ private: manifestsOuter, manifestsOuter, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); std::vector const cfgPublishersOuter; @@ -1231,7 +1231,7 @@ private: manifestsOuter, manifestsOuter, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const publisherSecret = randomSecretKey(); auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); @@ -1258,7 +1258,7 @@ private: manifestsOuter, manifestsOuter, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const masterPrivate = randomSecretKey(); auto const masterPublic = derivePublicKey(KeyType::Ed25519, masterPrivate); @@ -1292,7 +1292,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal, minQuorum); @@ -1348,7 +1348,7 @@ private: manifestsOuter, manifestsOuter, env.app().getTimeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); std::vector const emptyCfgKeys; @@ -1447,7 +1447,7 @@ private: manifestsOuter, manifestsOuter, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); std::vector const cfgPublishers; @@ -1483,7 +1483,7 @@ private: manifestsOuter, manifestsOuter, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); auto const localKey = randomNode(); @@ -1530,7 +1530,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); hash_set activeValidators; @@ -1618,7 +1618,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); hash_set activeValidators; @@ -1825,7 +1825,7 @@ private: manifests, manifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); // Empty list has no expiration @@ -1847,7 +1847,7 @@ private: manifests, manifests, env.app().getTimeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); std::vector validators = {randomValidator()}; @@ -1986,7 +1986,7 @@ private: manifests, manifests, env.timeKeeper(), - env.app().config().legacy(kSECTION_DATABASE_PATH), + env.app().config().legacy(Sections::kDATABASE_PATH), env.journal, minimumQuorum); @@ -2582,7 +2582,7 @@ private: valManifests, pubManifests, env.timeKeeper(), - app.config().legacy(kSECTION_DATABASE_PATH), + app.config().legacy(Sections::kDATABASE_PATH), env.journal); std::vector cfgPublishers; diff --git a/src/test/core/Config_test.cpp b/src/test/core/Config_test.cpp index f89bfcfb0c..9bbc419f7c 100644 --- a/src/test/core/Config_test.cpp +++ b/src/test/core/Config_test.cpp @@ -294,9 +294,9 @@ port_wss_admin c.loadFromString(toLoad); - BEAST_EXPECT(c.legacy(kSECTION_SSL_VERIFY) == "0"); + BEAST_EXPECT(c.legacy(Sections::kSSL_VERIFY) == "0"); expectException( - [&c] { [[maybe_unused]] auto _ = c.legacy(kSECTION_SERVER); }); // not a single line + [&c] { [[maybe_unused]] auto _ = c.legacy(Sections::kSERVER); }); // not a single line // set a legacy value BEAST_EXPECT(c.legacy("not_in_file").empty()); @@ -329,9 +329,9 @@ port_wss_admin // Load the config file from the current directory and verify it. Config c; c.setup("", true, false, true); - BEAST_EXPECT(c.section(kSECTION_DEBUG_LOGFILE).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kDEBUG_LOGFILE).values().size() == 1); BEAST_EXPECT( - c.section(kSECTION_DEBUG_LOGFILE).values()[0] == + c.section(Sections::kDEBUG_LOGFILE).values()[0] == "/Users/dummy/xrpld/config/log/debug.log"); } @@ -368,9 +368,9 @@ port_wss_admin // Load the config file from the config directory and verify it. Config c; c.setup("", true, false, true); - BEAST_EXPECT(c.section(kSECTION_DEBUG_LOGFILE).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kDEBUG_LOGFILE).values().size() == 1); BEAST_EXPECT( - c.section(kSECTION_DEBUG_LOGFILE).values()[0] == + c.section(Sections::kDEBUG_LOGFILE).values()[0] == "/Users/dummy/xrpld/config/log/debug.log"); // Restore the environment variables. @@ -404,9 +404,9 @@ port_wss_admin // Load the config file from the config directory and verify it. Config c; c.setup("", true, false, true); - BEAST_EXPECT(c.section(kSECTION_DEBUG_LOGFILE).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kDEBUG_LOGFILE).values().size() == 1); BEAST_EXPECT( - c.section(kSECTION_DEBUG_LOGFILE).values()[0] == + c.section(Sections::kDEBUG_LOGFILE).values()[0] == "/Users/dummy/xrpld/config/log/debug.log"); // Restore the environment variables. @@ -436,13 +436,13 @@ port_wss_admin // Dummy test - do we get back what we put in Config c; c.loadFromString(boost::str(cc % dataDirAbs.string())); - BEAST_EXPECT(c.legacy(kSECTION_DATABASE_PATH) == dataDirAbs.string()); + BEAST_EXPECT(c.legacy(Sections::kDATABASE_PATH) == dataDirAbs.string()); } { // Rel paths should convert to abs paths Config c; c.loadFromString(boost::str(cc % dataDirRel.string())); - BEAST_EXPECT(c.legacy(kSECTION_DATABASE_PATH) == dataDirAbs.string()); + BEAST_EXPECT(c.legacy(Sections::kDATABASE_PATH) == dataDirAbs.string()); } { // No db section. @@ -450,7 +450,7 @@ port_wss_admin // load will not. Config c; c.loadFromString(""); - BEAST_EXPECT(c.legacy(kSECTION_DATABASE_PATH).empty()); + BEAST_EXPECT(c.legacy(Sections::kDATABASE_PATH).empty()); } } { @@ -464,7 +464,7 @@ port_wss_admin auto const& c(g.config()); BEAST_EXPECT(g.dataDirExists()); BEAST_EXPECT(g.configFileExists()); - BEAST_EXPECT(c.legacy(kSECTION_DATABASE_PATH) == dataDirAbs.string()); + BEAST_EXPECT(c.legacy(Sections::kDATABASE_PATH) == dataDirAbs.string()); } { // read from file relative path @@ -474,7 +474,7 @@ port_wss_admin std::string const nativeDbPath = absolute(path(dbPath)).string(); BEAST_EXPECT(g.dataDirExists()); BEAST_EXPECT(g.configFileExists()); - BEAST_EXPECT(c.legacy(kSECTION_DATABASE_PATH) == nativeDbPath); + BEAST_EXPECT(c.legacy(Sections::kDATABASE_PATH) == nativeDbPath); } { // read from file no path @@ -484,7 +484,7 @@ port_wss_admin absolute(g.subdir() / path(Config::kDATABASE_DIR_NAME)).string(); BEAST_EXPECT(g.dataDirExists()); BEAST_EXPECT(g.configFileExists()); - BEAST_EXPECT(c.legacy(kSECTION_DATABASE_PATH) == nativeDbPath); + BEAST_EXPECT(c.legacy(Sections::kDATABASE_PATH) == nativeDbPath); } } @@ -653,8 +653,8 @@ nHUhG1PgAG8H8myUENypM35JgfqXAKNQvRVVAFDRzJrny5eZN8d5 nHBu9PTL9dn2GuZtdW4U2WzBwffyX9qsQCd9CNU4Z5YG3PQfViM8 )xrpldConfig"); c.loadFromString(toLoad); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE).empty()); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 5); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE).empty()); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 5); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == std::nullopt); } { @@ -672,19 +672,19 @@ trust-these-validators.gov 1 )xrpldConfig"); c.loadFromString(toLoad); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); BEAST_EXPECT( - c.section(kSECTION_VALIDATOR_LIST_SITES).values()[0] == "xrpl-validators.com"); + c.section(Sections::kVALIDATOR_LIST_SITES).values()[0] == "xrpl-validators.com"); BEAST_EXPECT( - c.section(kSECTION_VALIDATOR_LIST_SITES).values()[1] == + c.section(Sections::kVALIDATOR_LIST_SITES).values()[1] == "trust-these-validators.gov"); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 1); BEAST_EXPECT( - c.section(kSECTION_VALIDATOR_LIST_KEYS).values()[0] == + c.section(Sections::kVALIDATOR_LIST_KEYS).values()[0] == "021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801" "E566"); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values()[0] == "1"); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values()[0] == "1"); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == std::size_t(1)); } { @@ -702,19 +702,19 @@ trust-these-validators.gov 0 )xrpldConfig"); c.loadFromString(toLoad); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); BEAST_EXPECT( - c.section(kSECTION_VALIDATOR_LIST_SITES).values()[0] == "xrpl-validators.com"); + c.section(Sections::kVALIDATOR_LIST_SITES).values()[0] == "xrpl-validators.com"); BEAST_EXPECT( - c.section(kSECTION_VALIDATOR_LIST_SITES).values()[1] == + c.section(Sections::kVALIDATOR_LIST_SITES).values()[1] == "trust-these-validators.gov"); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 1); BEAST_EXPECT( - c.section(kSECTION_VALIDATOR_LIST_KEYS).values()[0] == + c.section(Sections::kVALIDATOR_LIST_KEYS).values()[0] == "021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801" "E566"); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values()[0] == "0"); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values()[0] == "0"); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == std::nullopt); } { @@ -831,11 +831,11 @@ trust-these-validators.gov Config c; boost::format cc("[validators_file]\n%1%\n"); c.loadFromString(boost::str(cc % vtg.validatorsFile())); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE) == vtg.validatorsFile()); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 8); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE) == vtg.validatorsFile()); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 8); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2); } { @@ -848,11 +848,11 @@ trust-these-validators.gov BEAST_EXPECT(vtg.validatorsFileExists()); BEAST_EXPECT(rcg.configFileExists()); auto const& c(rcg.config()); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE) == valFileName); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 8); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE) == valFileName); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 8); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2); } { @@ -865,11 +865,11 @@ trust-these-validators.gov BEAST_EXPECT(vtg.validatorsFileExists()); BEAST_EXPECT(rcg.configFileExists()); auto const& c(rcg.config()); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE) == valFilePath); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 8); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE) == valFilePath); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 8); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2); } { @@ -880,11 +880,11 @@ trust-these-validators.gov BEAST_EXPECT(vtg.validatorsFileExists()); BEAST_EXPECT(rcg.configFileExists()); auto const& c(rcg.config()); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE).empty()); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 8); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE).empty()); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 8); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2); } { @@ -899,11 +899,11 @@ trust-these-validators.gov *this, vtg.subdir(), "", Config::kCONFIG_FILE_NAME, vtg.validatorsFile(), false); BEAST_EXPECT(rcg.configFileExists()); auto const& c(rcg.config()); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE) == vtg.validatorsFile()); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 8); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 2); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE) == vtg.validatorsFile()); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 8); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 2); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2); } @@ -935,11 +935,11 @@ trust-these-validators.gov BEAST_EXPECT(vtg.validatorsFileExists()); Config c; c.loadFromString(boost::str(cc % vtg.validatorsFile())); - BEAST_EXPECT(c.legacy(kSECTION_VALIDATORS_FILE) == vtg.validatorsFile()); - BEAST_EXPECT(c.section(kSECTION_VALIDATORS).values().size() == 15); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_SITES).values().size() == 4); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_KEYS).values().size() == 3); - BEAST_EXPECT(c.section(kSECTION_VALIDATOR_LIST_THRESHOLD).values().size() == 1); + BEAST_EXPECT(c.legacy(Sections::kVALIDATORS_FILE) == vtg.validatorsFile()); + BEAST_EXPECT(c.section(Sections::kVALIDATORS).values().size() == 15); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_SITES).values().size() == 4); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_KEYS).values().size() == 3); + BEAST_EXPECT(c.section(Sections::kVALIDATOR_LIST_THRESHOLD).values().size() == 1); BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2); } { @@ -1018,7 +1018,7 @@ trust-these-validators.gov BEAST_EXPECT(!config.silent()); BEAST_EXPECT(!config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 256); - BEAST_EXPECT(!config.legacy(kSECTION_DATABASE_PATH).empty()); + BEAST_EXPECT(!config.legacy(Sections::kDATABASE_PATH).empty()); } { Config config; @@ -1031,7 +1031,7 @@ trust-these-validators.gov BEAST_EXPECT(!config.silent()); BEAST_EXPECT(!config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 256); - BEAST_EXPECT(!config.legacy(kSECTION_DATABASE_PATH).empty()); + BEAST_EXPECT(!config.legacy(Sections::kDATABASE_PATH).empty()); } { Config config; @@ -1044,7 +1044,7 @@ trust-these-validators.gov BEAST_EXPECT(config.silent()); BEAST_EXPECT(!config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 256); - BEAST_EXPECT(!config.legacy(kSECTION_DATABASE_PATH).empty()); + BEAST_EXPECT(!config.legacy(Sections::kDATABASE_PATH).empty()); } { Config config; @@ -1057,7 +1057,7 @@ trust-these-validators.gov BEAST_EXPECT(config.silent()); BEAST_EXPECT(!config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 256); - BEAST_EXPECT(!config.legacy(kSECTION_DATABASE_PATH).empty()); + BEAST_EXPECT(!config.legacy(Sections::kDATABASE_PATH).empty()); } { Config config; @@ -1070,7 +1070,7 @@ trust-these-validators.gov BEAST_EXPECT(!config.silent()); BEAST_EXPECT(config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 0); - BEAST_EXPECT(config.legacy(kSECTION_DATABASE_PATH).empty() == !explicitPath); + BEAST_EXPECT(config.legacy(Sections::kDATABASE_PATH).empty() == !explicitPath); } { Config config; @@ -1083,7 +1083,7 @@ trust-these-validators.gov BEAST_EXPECT(!config.silent()); BEAST_EXPECT(config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 0); - BEAST_EXPECT(config.legacy(kSECTION_DATABASE_PATH).empty() == !explicitPath); + BEAST_EXPECT(config.legacy(Sections::kDATABASE_PATH).empty() == !explicitPath); } { Config config; @@ -1096,7 +1096,7 @@ trust-these-validators.gov BEAST_EXPECT(config.silent()); BEAST_EXPECT(config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 0); - BEAST_EXPECT(config.legacy(kSECTION_DATABASE_PATH).empty() == !explicitPath); + BEAST_EXPECT(config.legacy(Sections::kDATABASE_PATH).empty() == !explicitPath); } { Config config; @@ -1109,7 +1109,7 @@ trust-these-validators.gov BEAST_EXPECT(config.silent()); BEAST_EXPECT(config.standalone()); BEAST_EXPECT(config.LEDGER_HISTORY == 0); - BEAST_EXPECT(config.legacy(kSECTION_DATABASE_PATH).empty() == !explicitPath); + BEAST_EXPECT(config.legacy(Sections::kDATABASE_PATH).empty() == !explicitPath); } } @@ -1118,16 +1118,16 @@ trust-these-validators.gov { detail::FileCfgGuard const cfg(*this, "testPort", "", Config::kCONFIG_FILE_NAME, ""); auto const& conf = cfg.config(); - if (!BEAST_EXPECT(conf.exists(kSECTION_PORT_RPC))) + if (!BEAST_EXPECT(conf.exists(Sections::kPORT_RPC))) return; - if (!BEAST_EXPECT(conf.exists(kSECTION_PORT_WSS_ADMIN))) + if (!BEAST_EXPECT(conf.exists(Sections::kPORT_WSS_ADMIN))) return; ParsedPort rpc; - if (!unexcept([&]() { parsePort(rpc, conf[kSECTION_PORT_RPC], log); })) + if (!unexcept([&]() { parsePort(rpc, conf[Sections::kPORT_RPC], log); })) return; BEAST_EXPECT(rpc.admin_nets_v4.size() + rpc.admin_nets_v6.size() == 2); ParsedPort wss; - if (!unexcept([&]() { parsePort(wss, conf[kSECTION_PORT_WSS_ADMIN], log); })) + if (!unexcept([&]() { parsePort(wss, conf[Sections::kPORT_WSS_ADMIN], log); })) return; BEAST_EXPECT(wss.admin_nets_v4.size() + wss.admin_nets_v6.size() == 1); } @@ -1182,14 +1182,15 @@ r.ripple.com 51235 )"); cfg.loadFromString(toLoad); BEAST_EXPECT( - cfg.exists(kSECTION_PORT_RPC) && cfg.section(kSECTION_PORT_RPC).lines().empty() && - cfg.section(kSECTION_PORT_RPC).values().empty()); + cfg.exists(Sections::kPORT_RPC) && cfg.section(Sections::kPORT_RPC).lines().empty() && + cfg.section(Sections::kPORT_RPC).values().empty()); BEAST_EXPECT( - cfg.exists(kSECTION_IPS) && cfg.section(kSECTION_IPS).lines().size() == 1 && - cfg.section(kSECTION_IPS).values().size() == 1); + cfg.exists(Sections::kIPS) && cfg.section(Sections::kIPS).lines().size() == 1 && + cfg.section(Sections::kIPS).values().size() == 1); BEAST_EXPECT( - cfg.exists(kSECTION_IPS_FIXED) && cfg.section(kSECTION_IPS_FIXED).lines().size() == 2 && - cfg.section(kSECTION_IPS_FIXED).values().size() == 2); + cfg.exists(Sections::kIPS_FIXED) && + cfg.section(Sections::kIPS_FIXED).lines().size() == 2 && + cfg.section(Sections::kIPS_FIXED).values().size() == 2); } void @@ -1237,15 +1238,15 @@ r.ripple.com:51235 )"); cfg.loadFromString(toLoad); BEAST_EXPECT( - cfg.exists(kSECTION_PORT_RPC) && cfg.section(kSECTION_PORT_RPC).lines().empty() && - cfg.section(kSECTION_PORT_RPC).values().empty()); + cfg.exists(Sections::kPORT_RPC) && cfg.section(Sections::kPORT_RPC).lines().empty() && + cfg.section(Sections::kPORT_RPC).values().empty()); BEAST_EXPECT( - cfg.exists(kSECTION_IPS) && cfg.section(kSECTION_IPS).lines().size() == 1 && - cfg.section(kSECTION_IPS).values().size() == 1); + cfg.exists(Sections::kIPS) && cfg.section(Sections::kIPS).lines().size() == 1 && + cfg.section(Sections::kIPS).values().size() == 1); BEAST_EXPECT( - cfg.exists(kSECTION_IPS_FIXED) && - cfg.section(kSECTION_IPS_FIXED).lines().size() == 15 && - cfg.section(kSECTION_IPS_FIXED).values().size() == 15); + cfg.exists(Sections::kIPS_FIXED) && + cfg.section(Sections::kIPS_FIXED).lines().size() == 15 && + cfg.section(Sections::kIPS_FIXED).values().size() == 15); BEAST_EXPECT(cfg.IPS[0] == "r.ripple.com 51235"); BEAST_EXPECT(cfg.IPS_FIXED[0] == "s1.ripple.com 51235"); @@ -1336,18 +1337,18 @@ r.ripple.com:51235 Section s; s.append("online_delete = 3000"); std::uint32_t od = 0; - BEAST_EXPECT(set(od, kKEY_ONLINE_DELETE, s)); + BEAST_EXPECT(set(od, Keys::kONLINE_DELETE, s)); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - BEAST_EXPECTS(od == 3000, *(s.get(kKEY_ONLINE_DELETE))); + BEAST_EXPECTS(od == 3000, *(s.get(Keys::kONLINE_DELETE))); } { Section s; s.append("online_delete = 2000 #my comment on this"); std::uint32_t od = 0; - BEAST_EXPECT(set(od, kKEY_ONLINE_DELETE, s)); + BEAST_EXPECT(set(od, Keys::kONLINE_DELETE, s)); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - BEAST_EXPECTS(od == 2000, *(s.get(kKEY_ONLINE_DELETE))); + BEAST_EXPECTS(od == 2000, *(s.get(Keys::kONLINE_DELETE))); } } diff --git a/src/test/core/SociDB_test.cpp b/src/test/core/SociDB_test.cpp index 6d102b2d3e..1727132ee4 100644 --- a/src/test/core/SociDB_test.cpp +++ b/src/test/core/SociDB_test.cpp @@ -32,10 +32,10 @@ private: static void setupSQLiteConfig(BasicConfig& config, boost::filesystem::path const& dbPath) { - config.overwrite(kSECTION_SQDB, kKEY_BACKEND, "sqlite"); + config.overwrite(Sections::kSQDB, Keys::kBACKEND, "sqlite"); auto value = dbPath.string(); if (!value.empty()) - config.legacy(kSECTION_DATABASE_PATH, value); + config.legacy(Sections::kDATABASE_PATH, value); } static void diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index a756750fc4..7950bebc02 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -864,7 +864,7 @@ public: jtx::Env const env{ *this, jtx::envconfig([](std::unique_ptr cfg) { - (*cfg).deprecatedClearSection(kSECTION_PORT_RPC); + (*cfg).deprecatedClearSection(Sections::kPORT_RPC); return cfg; }), nullptr, diff --git a/src/test/jtx/impl/JSONRPCClient.cpp b/src/test/jtx/impl/JSONRPCClient.cpp index 2485296725..a4259988c7 100644 --- a/src/test/jtx/impl/JSONRPCClient.cpp +++ b/src/test/jtx/impl/JSONRPCClient.cpp @@ -40,8 +40,8 @@ class JSONRPCClient : public AbstractClient { auto& log = std::cerr; ParsedPort common; - parsePort(common, cfg[kSECTION_SERVER], log); - for (auto const& name : cfg.section(kSECTION_SERVER).values()) + parsePort(common, cfg[Sections::kSERVER], log); + for (auto const& name : cfg.section(Sections::kSERVER).values()) { if (!cfg.exists(name)) continue; diff --git a/src/test/jtx/impl/WSClient.cpp b/src/test/jtx/impl/WSClient.cpp index f7579ca6b3..681c619887 100644 --- a/src/test/jtx/impl/WSClient.cpp +++ b/src/test/jtx/impl/WSClient.cpp @@ -62,9 +62,9 @@ class WSClientImpl : public WSClient { auto& log = std::cerr; ParsedPort common; - parsePort(common, cfg[kSECTION_SERVER], log); + parsePort(common, cfg[Sections::kSERVER], log); auto const ps = v2 ? "ws2" : "ws"; - for (auto const& name : cfg.section(kSECTION_SERVER).values()) + for (auto const& name : cfg.section(Sections::kSERVER).values()) { if (!cfg.exists(name)) continue; diff --git a/src/test/jtx/impl/envconfig.cpp b/src/test/jtx/impl/envconfig.cpp index e8c93a3ff4..54c185d2e2 100644 --- a/src/test/jtx/impl/envconfig.cpp +++ b/src/test/jtx/impl/envconfig.cpp @@ -28,33 +28,33 @@ setupConfigForUnitTests(Config& cfg) // The Beta API (currently v2) is always available to tests cfg.BETA_RPC_API = true; - cfg.overwrite(kSECTION_NODE_DATABASE, kKEY_TYPE, "memory"); - cfg.overwrite(kSECTION_NODE_DATABASE, kKEY_PATH, "main"); - cfg.deprecatedClearSection(kSECTION_IMPORT_NODE_DATABASE); - cfg.legacy(kSECTION_DATABASE_PATH, ""); + cfg.overwrite(Sections::kNODE_DATABASE, Keys::kTYPE, "memory"); + cfg.overwrite(Sections::kNODE_DATABASE, Keys::kPATH, "main"); + cfg.deprecatedClearSection(Sections::kIMPORT_NODE_DATABASE); + cfg.legacy(Sections::kDATABASE_PATH, ""); cfg.setupControl(true, true, true); - cfg[kSECTION_SERVER].append(kSECTION_PORT_PEER); - cfg[kSECTION_PORT_PEER].set(kKEY_IP, getEnvLocalhostAddr()); + cfg[Sections::kSERVER].append(Sections::kPORT_PEER); + cfg[Sections::kPORT_PEER].set(Keys::kIP, getEnvLocalhostAddr()); // Using port 0 asks the operating system to allocate an unused port, which // can be obtained after a "bind" call. // Works for all system (Linux, Windows, Unix, Mac). // Check https://man7.org/linux/man-pages/man7/ip.7.html // "ip_local_port_range" section for more info - cfg[kSECTION_PORT_PEER].set(kKEY_PORT, "0"); - cfg[kSECTION_PORT_PEER].set(kKEY_PROTOCOL, "peer"); + cfg[Sections::kPORT_PEER].set(Keys::kPORT, "0"); + cfg[Sections::kPORT_PEER].set(Keys::kPROTOCOL, "peer"); - cfg[kSECTION_SERVER].append(kSECTION_PORT_RPC); - cfg[kSECTION_PORT_RPC].set(kKEY_IP, getEnvLocalhostAddr()); - cfg[kSECTION_PORT_RPC].set(kKEY_ADMIN, getEnvLocalhostAddr()); - cfg[kSECTION_PORT_RPC].set(kKEY_PORT, "0"); - cfg[kSECTION_PORT_RPC].set(kKEY_PROTOCOL, "http,ws2"); + cfg[Sections::kSERVER].append(Sections::kPORT_RPC); + cfg[Sections::kPORT_RPC].set(Keys::kIP, getEnvLocalhostAddr()); + cfg[Sections::kPORT_RPC].set(Keys::kADMIN, getEnvLocalhostAddr()); + cfg[Sections::kPORT_RPC].set(Keys::kPORT, "0"); + cfg[Sections::kPORT_RPC].set(Keys::kPROTOCOL, "http,ws2"); - cfg[kSECTION_SERVER].append(kSECTION_PORT_WS); - cfg[kSECTION_PORT_WS].set(kKEY_IP, getEnvLocalhostAddr()); - cfg[kSECTION_PORT_WS].set(kKEY_ADMIN, getEnvLocalhostAddr()); - cfg[kSECTION_PORT_WS].set(kKEY_PORT, "0"); - cfg[kSECTION_PORT_WS].set(kKEY_PROTOCOL, "ws"); + cfg[Sections::kSERVER].append(Sections::kPORT_WS); + cfg[Sections::kPORT_WS].set(Keys::kIP, getEnvLocalhostAddr()); + cfg[Sections::kPORT_WS].set(Keys::kADMIN, getEnvLocalhostAddr()); + cfg[Sections::kPORT_WS].set(Keys::kPORT, "0"); + cfg[Sections::kPORT_WS].set(Keys::kPROTOCOL, "ws"); cfg.SSL_VERIFY = false; } @@ -63,35 +63,35 @@ namespace jtx { std::unique_ptr noAdmin(std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_ADMIN, ""); - (*cfg)[kSECTION_PORT_WS].set(kKEY_ADMIN, ""); + (*cfg)[Sections::kPORT_RPC].set(Keys::kADMIN, ""); + (*cfg)[Sections::kPORT_WS].set(Keys::kADMIN, ""); return cfg; } std::unique_ptr secureGateway(std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_ADMIN, ""); - (*cfg)[kSECTION_PORT_WS].set(kKEY_ADMIN, ""); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_SECURE_GATEWAY, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_RPC].set(Keys::kADMIN, ""); + (*cfg)[Sections::kPORT_WS].set(Keys::kADMIN, ""); + (*cfg)[Sections::kPORT_RPC].set(Keys::kSECURE_GATEWAY, getEnvLocalhostAddr()); return cfg; } std::unique_ptr adminLocalnet(std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_ADMIN, "127.0.0.0/8"); - (*cfg)[kSECTION_PORT_WS].set(kKEY_ADMIN, "127.0.0.0/8"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kADMIN, "127.0.0.0/8"); + (*cfg)[Sections::kPORT_WS].set(Keys::kADMIN, "127.0.0.0/8"); return cfg; } std::unique_ptr secureGatewayLocalnet(std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_ADMIN, ""); - (*cfg)[kSECTION_PORT_WS].set(kKEY_ADMIN, ""); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_SECURE_GATEWAY, "127.0.0.0/8"); - (*cfg)[kSECTION_PORT_WS].set(kKEY_SECURE_GATEWAY, "127.0.0.0/8"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kADMIN, ""); + (*cfg)[Sections::kPORT_WS].set(Keys::kADMIN, ""); + (*cfg)[Sections::kPORT_RPC].set(Keys::kSECURE_GATEWAY, "127.0.0.0/8"); + (*cfg)[Sections::kPORT_WS].set(Keys::kSECURE_GATEWAY, "127.0.0.0/8"); return cfg; } std::unique_ptr @@ -107,7 +107,7 @@ std::unique_ptr validator(std::unique_ptr cfg, std::string const& seed) { // If the config has valid validation keys then we run as a validator. - cfg->section(kSECTION_VALIDATION_SEED) + cfg->section(Sections::kVALIDATION_SEED) .append(std::vector{seed.empty() ? kDEFAULTSEED : seed}); return cfg; } @@ -115,20 +115,20 @@ validator(std::unique_ptr cfg, std::string const& seed) std::unique_ptr addGrpcConfig(std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); return cfg; } std::unique_ptr addGrpcConfigWithSecureGateway(std::unique_ptr cfg, std::string const& secureGateway) { - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, getEnvLocalhostAddr()); // Check https://man7.org/linux/man-pages/man7/ip.7.html // "ip_local_port_range" section for using 0 ports - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SECURE_GATEWAY, secureGateway); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSECURE_GATEWAY, secureGateway); return cfg; } @@ -138,10 +138,10 @@ addGrpcConfigWithTLS( std::string const& certPath, std::string const& keyPath) { - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, certPath); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, keyPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, certPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, keyPath); return cfg; } @@ -152,11 +152,11 @@ addGrpcConfigWithTLSAndClientCA( std::string const& keyPath, std::string const& clientCAPath) { - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, certPath); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, keyPath); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CLIENT_CA, clientCAPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, certPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, keyPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CLIENT_CA, clientCAPath); return cfg; } @@ -167,11 +167,11 @@ addGrpcConfigWithTLSAndCertChain( std::string const& keyPath, std::string const& certChainPath) { - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_PORT, "0"); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT, certPath); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_KEY, keyPath); - (*cfg)[kSECTION_PORT_GRPC].set(kKEY_SSL_CERT_CHAIN, certChainPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kPORT, "0"); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT, certPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_KEY, keyPath); + (*cfg)[Sections::kPORT_GRPC].set(Keys::kSSL_CERT_CHAIN, certChainPath); return cfg; } @@ -181,13 +181,13 @@ makeConfig( std::map extraVoting) { auto p = test::jtx::envconfig(); - auto& section = p->section(kSECTION_TRANSACTION_QUEUE); - section.set(kKEY_LEDGERS_IN_QUEUE, "2"); - section.set(kKEY_MINIMUM_QUEUE_SIZE, "2"); - section.set(kKEY_MIN_LEDGERS_TO_COMPUTE_SIZE_LIMIT, "3"); - section.set(kKEY_MAX_LEDGER_COUNTS_TO_STORE, "100"); - section.set(kKEY_RETRY_SEQUENCE_PERCENT, "25"); - section.set(kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT, "0"); + auto& section = p->section(Sections::kTRANSACTION_QUEUE); + section.set(Keys::kLEDGERS_IN_QUEUE, "2"); + section.set(Keys::kMINIMUM_QUEUE_SIZE, "2"); + section.set(Keys::kMIN_LEDGERS_TO_COMPUTE_SIZE_LIMIT, "3"); + section.set(Keys::kMAX_LEDGER_COUNTS_TO_STORE, "100"); + section.set(Keys::kRETRY_SEQUENCE_PERCENT, "25"); + section.set(Keys::kNORMAL_CONSENSUS_INCREASE_PERCENT, "0"); for (auto const& [k, v] : extraTxQ) section.set(k, v); @@ -196,14 +196,14 @@ makeConfig( // a FeeVote if (!extraVoting.empty()) { - auto& votingSection = p->section(kSECTION_VOTING); + auto& votingSection = p->section(Sections::kVOTING); for (auto const& [k, v] : extraVoting) { votingSection.set(k, v); } // In order for the vote to occur, we must run as a validator - p->section(kSECTION_VALIDATION_SEED).legacy("shUwVw52ofnCUX5m7kPTKzJdr4HEH"); + p->section(Sections::kVALIDATION_SEED).legacy("shUwVw52ofnCUX5m7kPTKzJdr4HEH"); } return p; } diff --git a/src/test/nodestore/Backend_test.cpp b/src/test/nodestore/Backend_test.cpp index f4189b75c9..ee8012f6b6 100644 --- a/src/test/nodestore/Backend_test.cpp +++ b/src/test/nodestore/Backend_test.cpp @@ -32,8 +32,8 @@ public: Section params; beast::TempDir const tempDir; - params.set(kKEY_TYPE, type); - params.set(kKEY_PATH, tempDir.path()); + params.set(Keys::kTYPE, type); + params.set(Keys::kPATH, tempDir.path()); beast::xor_shift_engine rng(seedValue); diff --git a/src/test/nodestore/Database_test.cpp b/src/test/nodestore/Database_test.cpp index eb1bbce7e8..966c7b59bb 100644 --- a/src/test/nodestore/Database_test.cpp +++ b/src/test/nodestore/Database_test.cpp @@ -72,8 +72,8 @@ public: Env env = [&]() { auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "high"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "high"); } p->LEDGER_HISTORY = 100'000'000; @@ -101,8 +101,8 @@ public: Env env = [&]() { auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "low"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "low"); } p->LEDGER_HISTORY = 100'000'000; @@ -130,10 +130,10 @@ public: Env env = [&]() { auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_JOURNAL_MODE, "off"); - section.set(kKEY_SYNCHRONOUS, "extra"); - section.set(kKEY_TEMP_STORE, "default"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kJOURNAL_MODE, "off"); + section.set(Keys::kSYNCHRONOUS, "extra"); + section.set(Keys::kTEMP_STORE, "default"); } return Env( @@ -162,10 +162,10 @@ public: Env env = [&]() { auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_JOURNAL_MODE, "off"); - section.set(kKEY_SYNCHRONOUS, "extra"); - section.set(kKEY_TEMP_STORE, "default"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kJOURNAL_MODE, "off"); + section.set(Keys::kSYNCHRONOUS, "extra"); + section.set(Keys::kTEMP_STORE, "default"); } p->LEDGER_HISTORY = 50'000'000; @@ -198,11 +198,11 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "low"); - section.set(kKEY_JOURNAL_MODE, "off"); - section.set(kKEY_SYNCHRONOUS, "extra"); - section.set(kKEY_TEMP_STORE, "default"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "low"); + section.set(Keys::kJOURNAL_MODE, "off"); + section.set(Keys::kSYNCHRONOUS, "extra"); + section.set(Keys::kTEMP_STORE, "default"); } try @@ -229,9 +229,9 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "high"); - section.set(kKEY_JOURNAL_MODE, "off"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "high"); + section.set(Keys::kJOURNAL_MODE, "off"); } try @@ -258,9 +258,9 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "low"); - section.set(kKEY_SYNCHRONOUS, "extra"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "low"); + section.set(Keys::kSYNCHRONOUS, "extra"); } try @@ -287,9 +287,9 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "high"); - section.set(kKEY_TEMP_STORE, "default"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "high"); + section.set(Keys::kTEMP_STORE, "default"); } try @@ -316,8 +316,8 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SAFETY_LEVEL, "slow"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSAFETY_LEVEL, "slow"); } try @@ -344,8 +344,8 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_JOURNAL_MODE, "fast"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kJOURNAL_MODE, "fast"); } try @@ -372,8 +372,8 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_SYNCHRONOUS, "instant"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kSYNCHRONOUS, "instant"); } try @@ -400,8 +400,8 @@ public: auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_TEMP_STORE, "network"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kTEMP_STORE, "network"); } try @@ -435,9 +435,9 @@ public: Env env = [&]() { auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_PAGE_SIZE, "512"); - section.set(kKEY_JOURNAL_SIZE_LIMIT, "2582080"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kPAGE_SIZE, "512"); + section.set(Keys::kJOURNAL_SIZE_LIMIT, "2582080"); } return Env(*this, std::move(p)); }(); @@ -456,8 +456,8 @@ public: bool found = false; auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_PAGE_SIZE, "256"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kPAGE_SIZE, "256"); } try { @@ -479,8 +479,8 @@ public: bool found = false; auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_PAGE_SIZE, "131072"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kPAGE_SIZE, "131072"); } try { @@ -502,8 +502,8 @@ public: bool found = false; auto p = test::jtx::envconfig(); { - auto& section = p->section(kSECTION_SQLITE); - section.set(kKEY_PAGE_SIZE, "513"); + auto& section = p->section(Sections::kSQLITE); + section.set(Keys::kPAGE_SIZE, "513"); } try { @@ -533,8 +533,8 @@ public: beast::TempDir const nodeDb; Section srcParams; - srcParams.set(kKEY_TYPE, srcBackendType); - srcParams.set(kKEY_PATH, nodeDb.path()); + srcParams.set(Keys::kTYPE, srcBackendType); + srcParams.set(Keys::kPATH, nodeDb.path()); // Create a batch auto batch = createPredictableBatch(kNUM_OBJECTS_TO_TEST, seedValue); @@ -556,8 +556,8 @@ public: // Set up the destination database beast::TempDir const destDb; Section destParams; - destParams.set(kKEY_TYPE, destBackendType); - destParams.set(kKEY_PATH, destDb.path()); + destParams.set(Keys::kTYPE, destBackendType); + destParams.set(Keys::kPATH, destDb.path()); std::unique_ptr dest = Manager::instance().makeDatabase(megabytes(4), scheduler, 2, destParams, journal_); @@ -594,8 +594,8 @@ public: beast::TempDir const nodeDb; Section nodeParams; - nodeParams.set(kKEY_TYPE, type); - nodeParams.set(kKEY_PATH, nodeDb.path()); + nodeParams.set(Keys::kTYPE, type); + nodeParams.set(Keys::kPATH, nodeDb.path()); beast::xor_shift_engine rng(seedValue); @@ -654,7 +654,7 @@ public: // Set an invalid earliest ledger sequence try { - nodeParams.set(kKEY_EARLIEST_SEQ, "0"); + nodeParams.set(Keys::kEARLIEST_SEQ, "0"); std::unique_ptr const db = Manager::instance().makeDatabase( megabytes(4), scheduler, 2, nodeParams, journal_); } @@ -665,7 +665,7 @@ public: { // Set a valid earliest ledger sequence - nodeParams.set(kKEY_EARLIEST_SEQ, "1"); + nodeParams.set(Keys::kEARLIEST_SEQ, "1"); std::unique_ptr db = Manager::instance().makeDatabase( megabytes(4), scheduler, 2, nodeParams, journal_); @@ -677,7 +677,7 @@ public: try { // Set to default earliest ledger sequence - nodeParams.set(kKEY_EARLIEST_SEQ, std::to_string(kXRP_LEDGER_EARLIEST_SEQ)); + nodeParams.set(Keys::kEARLIEST_SEQ, std::to_string(kXRP_LEDGER_EARLIEST_SEQ)); std::unique_ptr const db2 = Manager::instance().makeDatabase( megabytes(4), scheduler, 2, nodeParams, journal_); } diff --git a/src/test/nodestore/NuDBFactory_test.cpp b/src/test/nodestore/NuDBFactory_test.cpp index 056b68d2cf..319a73cc34 100644 --- a/src/test/nodestore/NuDBFactory_test.cpp +++ b/src/test/nodestore/NuDBFactory_test.cpp @@ -29,10 +29,10 @@ private: createSection(std::string const& path, std::string const& blockSize = "") { Section params; - params.set(kKEY_TYPE, "nudb"); - params.set(kKEY_PATH, path); + params.set(Keys::kTYPE, "nudb"); + params.set(Keys::kPATH, path); if (!blockSize.empty()) - params.set(kKEY_NUDB_BLOCK_SIZE, blockSize); + params.set(Keys::kNUDB_BLOCK_SIZE, blockSize); return params; } diff --git a/src/test/nodestore/Timing_test.cpp b/src/test/nodestore/Timing_test.cpp index 702f70038d..362ae48579 100644 --- a/src/test/nodestore/Timing_test.cpp +++ b/src/test/nodestore/Timing_test.cpp @@ -665,9 +665,10 @@ public: { beast::TempDir const tempDir; Section config = parse(configString); - config.set(kKEY_PATH, tempDir.path()); + config.set(Keys::kPATH, tempDir.path()); std::stringstream ss; - ss << std::left << setw(10) << get(config, kKEY_TYPE, std::string()) << std::right; + ss << std::left << setw(10) << get(config, Keys::kTYPE, std::string()) + << std::right; for (auto const& test : tests) { ss << " " << setw(w) << toString(doTest(test.second, config, params, journal)); diff --git a/src/test/rpc/AmendmentBlocked_test.cpp b/src/test/rpc/AmendmentBlocked_test.cpp index 4049be0850..a30fdb1f58 100644 --- a/src/test/rpc/AmendmentBlocked_test.cpp +++ b/src/test/rpc/AmendmentBlocked_test.cpp @@ -30,7 +30,7 @@ class AmendmentBlocked_test : public beast::unit_test::Suite { using namespace test::jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - cfg->loadFromString(std::string("[") + kSECTION_SIGNING_SUPPORT + "]\ntrue"); + cfg->loadFromString(std::string("[") + Sections::kSIGNING_SUPPORT + "]\ntrue"); return cfg; })}; auto const gw = Account{"gateway"}; diff --git a/src/test/rpc/Feature_test.cpp b/src/test/rpc/Feature_test.cpp index d22a3205e6..332b99d69c 100644 --- a/src/test/rpc/Feature_test.cpp +++ b/src/test/rpc/Feature_test.cpp @@ -276,8 +276,8 @@ class Feature_test : public beast::unit_test::Suite using namespace test::jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_ADMIN, ""); - (*cfg)[kSECTION_PORT_WS].set(kKEY_ADMIN, ""); + (*cfg)[Sections::kPORT_RPC].set(Keys::kADMIN, ""); + (*cfg)[Sections::kPORT_WS].set(Keys::kADMIN, ""); return cfg; })}; diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index a9a394de58..7410542e0f 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -2375,9 +2375,9 @@ public: testcase("autofill escalated fees"); using namespace test::jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - cfg->loadFromString(std::string("[") + kSECTION_SIGNING_SUPPORT + "]\ntrue"); - cfg->section(kSECTION_TRANSACTION_QUEUE) - .set(kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); + cfg->loadFromString(std::string("[") + Sections::kSIGNING_SUPPORT + "]\ntrue"); + cfg->section(Sections::kTRANSACTION_QUEUE) + .set(Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); return cfg; })}; LoadFeeTrack const& feeTrackOuter = env.app().getFeeTrack(); diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index ea672057a9..9575fd4afb 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -431,9 +431,9 @@ class LedgerRPC_test : public beast::unit_test::Suite testcase("Ledger with Queued Transactions"); using namespace test::jtx; auto cfg = envconfig([](std::unique_ptr cfg) { - auto& section = cfg->section(kSECTION_TRANSACTION_QUEUE); - section.set(kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); - section.set(kKEY_NORMAL_CONSENSUS_INCREASE_PERCENT, "0"); + auto& section = cfg->section(Sections::kTRANSACTION_QUEUE); + section.set(Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); + section.set(Keys::kNORMAL_CONSENSUS_INCREASE_PERCENT, "0"); return cfg; }); diff --git a/src/test/rpc/ManifestRPC_test.cpp b/src/test/rpc/ManifestRPC_test.cpp index 08a503bb76..188703aa62 100644 --- a/src/test/rpc/ManifestRPC_test.cpp +++ b/src/test/rpc/ManifestRPC_test.cpp @@ -48,7 +48,7 @@ public: using namespace jtx; std::string const key = "n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7"; Env env{*this, envconfig([&key](std::unique_ptr cfg) { - cfg->section(kSECTION_VALIDATORS).append(key); + cfg->section(Sections::kVALIDATORS).append(key); return cfg; })}; { diff --git a/src/test/rpc/RPCOverload_test.cpp b/src/test/rpc/RPCOverload_test.cpp index 42f86e3d60..3c718a93ae 100644 --- a/src/test/rpc/RPCOverload_test.cpp +++ b/src/test/rpc/RPCOverload_test.cpp @@ -29,7 +29,7 @@ public: testcase << "Overload " << (useWS ? "WS" : "HTTP") << " RPC client"; using namespace jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - cfg->loadFromString(std::string("[") + kSECTION_SIGNING_SUPPORT + "]\ntrue"); + cfg->loadFromString(std::string("[") + Sections::kSIGNING_SUPPORT + "]\ntrue"); return noAdmin(std::move(cfg)); })}; diff --git a/src/test/rpc/ServerInfo_test.cpp b/src/test/rpc/ServerInfo_test.cpp index e5d2ff4458..b7091be8ed 100644 --- a/src/test/rpc/ServerInfo_test.cpp +++ b/src/test/rpc/ServerInfo_test.cpp @@ -109,9 +109,9 @@ admin = 127.0.0.1 Env env(*this, makeValidatorConfig()); auto const& config = env.app().config(); - auto const rpcPort = config[kSECTION_PORT_RPC].get(kKEY_PORT); - auto const grpcPort = config[kSECTION_PORT_GRPC].get(kKEY_PORT); - auto const wsPort = config[kSECTION_PORT_WS].get(kKEY_PORT); + auto const rpcPort = config[Sections::kPORT_RPC].get(Keys::kPORT); + auto const grpcPort = config[Sections::kPORT_GRPC].get(Keys::kPORT); + auto const wsPort = config[Sections::kPORT_WS].get(Keys::kPORT); BEAST_EXPECT(grpcPort); BEAST_EXPECT(rpcPort); BEAST_EXPECT(wsPort); diff --git a/src/test/rpc/Simulate_test.cpp b/src/test/rpc/Simulate_test.cpp index 4ea8e7a148..fc9c5fe566 100644 --- a/src/test/rpc/Simulate_test.cpp +++ b/src/test/rpc/Simulate_test.cpp @@ -430,8 +430,8 @@ class Simulate_test : public beast::unit_test::Suite using namespace jtx; Env env(*this, envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_TRANSACTION_QUEUE) - .set(kKEY_MINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); + cfg->section(Sections::kTRANSACTION_QUEUE) + .set(Keys::kMINIMUM_TXN_IN_LEDGER_STANDALONE, "3"); return cfg; })); diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 869d5ba8b6..9f15d45dac 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -431,10 +431,10 @@ public: Env env{*this, singleThreadIo(envconfig(validator, "")), features}; auto& cfg = env.app().config(); - if (!BEAST_EXPECT(cfg.section(kSECTION_VALIDATION_SEED).empty())) + if (!BEAST_EXPECT(cfg.section(Sections::kVALIDATION_SEED).empty())) return; auto const parsedseed = - parseBase58(cfg.section(kSECTION_VALIDATION_SEED).values()[0]); + parseBase58(cfg.section(Sections::kVALIDATION_SEED).values()[0]); if (BEAST_EXPECT(parsedseed); not parsedseed.has_value()) return; diff --git a/src/test/rpc/ValidatorInfo_test.cpp b/src/test/rpc/ValidatorInfo_test.cpp index f5e747d735..d8871f4275 100644 --- a/src/test/rpc/ValidatorInfo_test.cpp +++ b/src/test/rpc/ValidatorInfo_test.cpp @@ -68,7 +68,7 @@ public: "5AqDedFv5TJa2w0i21eq3MYywLVJZnFOr7C0kw2AiTzSCjIzditQ8="; Env env{*this, envconfig([&tokenBlob](std::unique_ptr cfg) { - cfg->section(kSECTION_VALIDATOR_TOKEN).append(tokenBlob); + cfg->section(Sections::kVALIDATOR_TOKEN).append(tokenBlob); return cfg; })}; { diff --git a/src/test/rpc/ValidatorRPC_test.cpp b/src/test/rpc/ValidatorRPC_test.cpp index 699c417c6b..c60865ef80 100644 --- a/src/test/rpc/ValidatorRPC_test.cpp +++ b/src/test/rpc/ValidatorRPC_test.cpp @@ -90,7 +90,7 @@ public: *this, envconfig([&keys](std::unique_ptr cfg) { for (auto const& key : keys) - cfg->section(kSECTION_VALIDATORS).append(key); + cfg->section(Sections::kVALIDATORS).append(key); return cfg; }), }; @@ -200,8 +200,8 @@ public: Env env{ *this, envconfig([&](std::unique_ptr cfg) { - cfg->section(kSECTION_VALIDATOR_LIST_SITES).append(siteURI); - cfg->section(kSECTION_VALIDATOR_LIST_KEYS) + cfg->section(Sections::kVALIDATOR_LIST_SITES).append(siteURI); + cfg->section(Sections::kVALIDATOR_LIST_KEYS) .append(strHex(server->publisherPublic())); return cfg; }), @@ -260,8 +260,8 @@ public: Env env{ *this, envconfig([&](std::unique_ptr cfg) { - cfg->section(kSECTION_VALIDATOR_LIST_SITES).append(siteURI); - cfg->section(kSECTION_VALIDATOR_LIST_KEYS) + cfg->section(Sections::kVALIDATOR_LIST_SITES).append(siteURI); + cfg->section(Sections::kVALIDATOR_LIST_KEYS) .append(strHex(server->publisherPublic())); return cfg; }), @@ -323,8 +323,8 @@ public: Env env{ *this, envconfig([&](std::unique_ptr cfg) { - cfg->section(kSECTION_VALIDATOR_LIST_SITES).append(siteURI); - cfg->section(kSECTION_VALIDATOR_LIST_KEYS) + cfg->section(Sections::kVALIDATOR_LIST_SITES).append(siteURI); + cfg->section(Sections::kVALIDATOR_LIST_KEYS) .append(strHex(server->publisherPublic())); return cfg; }), @@ -416,8 +416,8 @@ public: Env env{ *this, envconfig([&](std::unique_ptr cfg) { - cfg->section(kSECTION_VALIDATOR_LIST_SITES).append(siteURI); - cfg->section(kSECTION_VALIDATOR_LIST_KEYS) + cfg->section(Sections::kVALIDATOR_LIST_SITES).append(siteURI); + cfg->section(Sections::kVALIDATOR_LIST_KEYS) .append(strHex(server->publisherPublic())); return cfg; }), diff --git a/src/test/server/ServerStatus_test.cpp b/src/test/server/ServerStatus_test.cpp index d73caebee1..4beddce735 100644 --- a/src/test/server/ServerStatus_test.cpp +++ b/src/test/server/ServerStatus_test.cpp @@ -57,22 +57,22 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En makeConfig(std::string const& proto, bool admin = true, bool credentials = false) { auto const sectionName = - boost::starts_with(proto, "h") ? kSECTION_PORT_RPC : kSECTION_PORT_WS; + boost::starts_with(proto, "h") ? Sections::kPORT_RPC : Sections::kPORT_WS; auto p = jtx::envconfig(); - p->overwrite(sectionName, kKEY_PROTOCOL, proto); + p->overwrite(sectionName, Keys::kPROTOCOL, proto); if (!admin) - p->overwrite(sectionName, kKEY_ADMIN, ""); + p->overwrite(sectionName, Keys::kADMIN, ""); if (credentials) { - (*p)[sectionName].set(kKEY_ADMIN_PASSWORD, "p"); - (*p)[sectionName].set(kKEY_ADMIN_USER, "u"); + (*p)[sectionName].set(Keys::kADMIN_PASSWORD, "p"); + (*p)[sectionName].set(Keys::kADMIN_USER, "u"); } p->overwrite( - boost::starts_with(proto, "h") ? kSECTION_PORT_WS : kSECTION_PORT_RPC, - kKEY_PROTOCOL, + boost::starts_with(proto, "h") ? Sections::kPORT_WS : Sections::kPORT_RPC, + Keys::kPROTOCOL, boost::starts_with(proto, "h") ? "ws" : "http"); if (proto == "https") @@ -80,11 +80,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En // this port is here to allow the env to create its internal client, // which requires an http endpoint to talk to. In the connection // failure test, this endpoint should never be used - (*p)[kSECTION_SERVER].append("port_alt"); - (*p)["port_alt"].set(kKEY_IP, getEnvLocalhostAddr()); - (*p)["port_alt"].set(kKEY_PORT, "7099"); - (*p)["port_alt"].set(kKEY_PROTOCOL, "http"); - (*p)["port_alt"].set(kKEY_ADMIN, getEnvLocalhostAddr()); + (*p)[Sections::kSERVER].append("port_alt"); + (*p)["port_alt"].set(Keys::kIP, getEnvLocalhostAddr()); + (*p)["port_alt"].set(Keys::kPORT, "7099"); + (*p)["port_alt"].set(Keys::kPROTOCOL, "http"); + (*p)["port_alt"].set(Keys::kADMIN, getEnvLocalhostAddr()); } return p; @@ -214,8 +214,8 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En boost::beast::http::response& resp, boost::system::error_code& ec) { - auto const port = env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT); - auto ip = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP); + auto const port = env.app().config()[Sections::kPORT_WS].get(Keys::kPORT); + auto ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) doRequest(yield, makeWSUpgrade(*ip, *port), *ip, *port, secure, resp, ec); return; @@ -231,8 +231,8 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En std::string const& body = "", MyFields const& fields = {}) { - auto const port = env.app().config()[kSECTION_PORT_RPC].get(kKEY_PORT); - auto const ip = env.app().config()[kSECTION_PORT_RPC].get(kKEY_IP); + auto const port = env.app().config()[Sections::kPORT_RPC].get(Keys::kPORT); + auto const ip = env.app().config()[Sections::kPORT_RPC].get(Keys::kIP); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) doRequest(yield, makeHTTPRequest(*ip, *port, body, fields), *ip, *port, secure, resp, ec); return; @@ -300,13 +300,13 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En if (admin && credentials) { - auto const user = - env.app().config()[protoWs ? kSECTION_PORT_WS : kSECTION_PORT_RPC].get( - "admin_user"); + auto const user = env.app() + .config()[protoWs ? Sections::kPORT_WS : Sections::kPORT_RPC] + .get("admin_user"); - auto const password = - env.app().config()[protoWs ? kSECTION_PORT_WS : kSECTION_PORT_RPC].get( - "admin_password"); + auto const password = env.app() + .config()[protoWs ? Sections::kPORT_WS : Sections::kPORT_RPC] + .get("admin_password"); // 1 - FAILS with wrong pass // NOLINTNEXTLINE(bugprone-unchecked-optional-access) @@ -371,7 +371,7 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En testcase("WS client to http server fails"); using namespace jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_PORT_WS).set(kKEY_PROTOCOL, "http,https"); + cfg->section(Sections::kPORT_WS).set(Keys::kPROTOCOL, "http,https"); return cfg; })}; @@ -402,8 +402,8 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En testcase("Status request"); using namespace jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_PORT_RPC).set(kKEY_PROTOCOL, "ws2,wss2"); - cfg->section(kSECTION_PORT_WS).set(kKEY_PROTOCOL, "http"); + cfg->section(Sections::kPORT_RPC).set(Keys::kPROTOCOL, "ws2,wss2"); + cfg->section(Sections::kPORT_WS).set(Keys::kPROTOCOL, "http"); return cfg; })}; @@ -436,12 +436,12 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En using namespace boost::asio; using namespace boost::beast::http; Env env{*this, envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_PORT_WS).set(kKEY_PROTOCOL, "ws2"); + cfg->section(Sections::kPORT_WS).set(Keys::kPROTOCOL, "ws2"); return cfg; })}; - auto const port = env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT); - auto const ip = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP); + auto const port = env.app().config()[Sections::kPORT_WS].get(Keys::kPORT); + auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP); boost::system::error_code ec; response resp; @@ -508,11 +508,11 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En using namespace test::jtx; Env env{*this, envconfig([secure](std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_USER, "me"); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PASSWORD, "secret"); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PROTOCOL, secure ? "https" : "http"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kUSER, "me"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPASSWORD, "secret"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPROTOCOL, secure ? "https" : "http"); if (secure) - (*cfg)[kSECTION_PORT_WS].set(kKEY_PROTOCOL, "http,ws"); + (*cfg)[Sections::kPORT_WS].set(Keys::kPROTOCOL, "http,ws"); return cfg; })}; @@ -538,10 +538,14 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En // NOLINTNEXTLINE(bugprone-unchecked-optional-access) auto const user = - env.app().config().section(kSECTION_PORT_RPC).get(kKEY_USER).value(); + env.app().config().section(Sections::kPORT_RPC).get(Keys::kUSER).value(); auto const pass = // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - env.app().config().section(kSECTION_PORT_RPC).get(kKEY_PASSWORD).value(); + env.app() + .config() + .section(Sections::kPORT_RPC) + .get(Keys::kPASSWORD) + .value(); // try with the correct user/pass, but not encoded auth.set("Authorization", "Basic " + user + ":" + pass); @@ -564,16 +568,16 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En using namespace boost::asio; using namespace boost::beast::http; Env env{*this, envconfig([&](std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_RPC].set(kKEY_LIMIT, std::to_string(limit)); + (*cfg)[Sections::kPORT_RPC].set(Keys::kLIMIT, std::to_string(limit)); return cfg; })}; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) auto const port = - env.app().config()[kSECTION_PORT_RPC].get(kKEY_PORT).value(); + env.app().config()[Sections::kPORT_RPC].get(Keys::kPORT).value(); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[kSECTION_PORT_RPC].get(kKEY_IP).value(); + auto const ip = env.app().config()[Sections::kPORT_RPC].get(Keys::kIP).value(); boost::system::error_code ec; io_context& ios = getIoContext(); @@ -625,15 +629,15 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En using namespace test::jtx; Env env{*this, envconfig([](std::unique_ptr cfg) { - (*cfg)[kSECTION_PORT_WS].set(kKEY_PROTOCOL, "wss"); + (*cfg)[Sections::kPORT_WS].set(Keys::kPROTOCOL, "wss"); return cfg; })}; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) auto const port = - env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT).value(); + env.app().config()[Sections::kPORT_WS].get(Keys::kPORT).value(); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP).value(); + auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP).value(); boost::beast::http::response resp; boost::system::error_code ec; doRequest(yield, makeWSUpgrade(ip, port), ip, port, true, resp, ec); @@ -652,9 +656,9 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En // NOLINTNEXTLINE(bugprone-unchecked-optional-access) auto const port = - env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT).value(); + env.app().config()[Sections::kPORT_WS].get(Keys::kPORT).value(); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP).value(); + auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP).value(); boost::beast::http::response resp; boost::system::error_code ec; // body content is required here to avoid being @@ -676,9 +680,9 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En // NOLINTNEXTLINE(bugprone-unchecked-optional-access) auto const port = - env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT).value(); + env.app().config()[Sections::kPORT_WS].get(Keys::kPORT).value(); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ip = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP).value(); + auto const ip = env.app().config()[Sections::kPORT_WS].get(Keys::kIP).value(); boost::system::error_code ec; io_context& ios = getIoContext(); @@ -754,7 +758,7 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En *this, validator( envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_PORT_RPC).set(kKEY_PROTOCOL, "http"); + cfg->section(Sections::kPORT_RPC).set(Keys::kPROTOCOL, "http"); return cfg; }), "")}; @@ -782,8 +786,8 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En BEAST_EXPECT(env.app().getOPs().getConsensusInfo()["validating"] == true); BEAST_EXPECT(!si[jss::state].isMember(jss::warnings)); - auto const portWs = env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT); - auto const ipWs = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP); + auto const portWs = env.app().config()[Sections::kPORT_WS].get(Keys::kPORT); + auto const ipWs = env.app().config()[Sections::kPORT_WS].get(Keys::kIP); boost::system::error_code ec; response resp; @@ -882,7 +886,7 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En *this, validator( envconfig([](std::unique_ptr cfg) { - cfg->section(kSECTION_PORT_RPC).set(kKEY_PROTOCOL, "http"); + cfg->section(Sections::kPORT_RPC).set(Keys::kPROTOCOL, "http"); return cfg; }), "")}; @@ -910,8 +914,8 @@ class ServerStatus_test : public beast::unit_test::Suite, public beast::test::En BEAST_EXPECT(env.app().getOPs().getConsensusInfo()["validating"] == true); BEAST_EXPECT(!si[jss::state].isMember(jss::warnings)); - auto const portWs = env.app().config()[kSECTION_PORT_WS].get(kKEY_PORT); - auto const ipWs = env.app().config()[kSECTION_PORT_WS].get(kKEY_IP); + auto const portWs = env.app().config()[Sections::kPORT_WS].get(Keys::kPORT); + auto const ipWs = env.app().config()[Sections::kPORT_WS].get(Keys::kIP); boost::system::error_code ec; response resp; diff --git a/src/test/server/Server_test.cpp b/src/test/server/Server_test.cpp index bbf77f290d..ad6eff5bb0 100644 --- a/src/test/server/Server_test.cpp +++ b/src/test/server/Server_test.cpp @@ -394,7 +394,7 @@ public: Env const env{ *this, envconfig([](std::unique_ptr cfg) { - (*cfg).deprecatedClearSection(kSECTION_PORT_RPC); + (*cfg).deprecatedClearSection(Sections::kPORT_RPC); return cfg; }), std::make_unique(&messages)}; @@ -405,8 +405,8 @@ public: Env const env{ *this, envconfig([](std::unique_ptr cfg) { - (*cfg).deprecatedClearSection(kSECTION_PORT_RPC); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_IP, getEnvLocalhostAddr()); + (*cfg).deprecatedClearSection(Sections::kPORT_RPC); + (*cfg)[Sections::kPORT_RPC].set(Keys::kIP, getEnvLocalhostAddr()); return cfg; }), std::make_unique(&messages)}; @@ -417,9 +417,9 @@ public: Env const env{ *this, envconfig([](std::unique_ptr cfg) { - (*cfg).deprecatedClearSection(kSECTION_PORT_RPC); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PORT, "0"); + (*cfg).deprecatedClearSection(Sections::kPORT_RPC); + (*cfg)[Sections::kPORT_RPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPORT, "0"); return cfg; }), std::make_unique(&messages)}; @@ -431,7 +431,7 @@ public: Env const env{ *this, envconfig([](std::unique_ptr cfg) { - (*cfg)[kSECTION_SERVER].set(kKEY_PORT, "0"); + (*cfg)[Sections::kSERVER].set(Keys::kPORT, "0"); return cfg; }), std::make_unique(&messages)}; @@ -443,10 +443,10 @@ public: Env const env{ *this, envconfig([](std::unique_ptr cfg) { - (*cfg).deprecatedClearSection(kSECTION_PORT_RPC); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PORT, "8081"); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PROTOCOL, ""); + (*cfg).deprecatedClearSection(Sections::kPORT_RPC); + (*cfg)[Sections::kPORT_RPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPORT, "8081"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPROTOCOL, ""); return cfg; }), std::make_unique(&messages)}; @@ -460,22 +460,22 @@ public: *this, envconfig([](std::unique_ptr cfg) { cfg = std::make_unique(); - cfg->overwrite(kSECTION_NODE_DATABASE, kKEY_TYPE, "memory"); - cfg->overwrite(kSECTION_NODE_DATABASE, kKEY_PATH, "main"); - cfg->deprecatedClearSection(kSECTION_IMPORT_NODE_DATABASE); - cfg->legacy(kSECTION_DATABASE_PATH, ""); + cfg->overwrite(Sections::kNODE_DATABASE, Keys::kTYPE, "memory"); + cfg->overwrite(Sections::kNODE_DATABASE, Keys::kPATH, "main"); + cfg->deprecatedClearSection(Sections::kIMPORT_NODE_DATABASE); + cfg->legacy(Sections::kDATABASE_PATH, ""); cfg->setupControl(true, true, true); - (*cfg)[kSECTION_PORT_PEER].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_PEER].set(kKEY_PORT, "8080"); - (*cfg)[kSECTION_PORT_PEER].set(kKEY_PROTOCOL, "peer"); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PORT, "8081"); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_PROTOCOL, "http,ws2"); - (*cfg)[kSECTION_PORT_RPC].set(kKEY_ADMIN, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_WS].set(kKEY_IP, getEnvLocalhostAddr()); - (*cfg)[kSECTION_PORT_WS].set(kKEY_PORT, "8082"); - (*cfg)[kSECTION_PORT_WS].set(kKEY_PROTOCOL, "ws"); - (*cfg)[kSECTION_PORT_WS].set(kKEY_ADMIN, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_PEER].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_PEER].set(Keys::kPORT, "8080"); + (*cfg)[Sections::kPORT_PEER].set(Keys::kPROTOCOL, "peer"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPORT, "8081"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kPROTOCOL, "http,ws2"); + (*cfg)[Sections::kPORT_RPC].set(Keys::kADMIN, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_WS].set(Keys::kIP, getEnvLocalhostAddr()); + (*cfg)[Sections::kPORT_WS].set(Keys::kPORT, "8082"); + (*cfg)[Sections::kPORT_WS].set(Keys::kPROTOCOL, "ws"); + (*cfg)[Sections::kPORT_WS].set(Keys::kADMIN, getEnvLocalhostAddr()); return cfg; }), std::make_unique(&messages)}; @@ -489,14 +489,14 @@ public: *this, envconfig([](std::unique_ptr cfg) { cfg = std::make_unique(); - cfg->overwrite(kSECTION_NODE_DATABASE, kKEY_TYPE, "memory"); - cfg->overwrite(kSECTION_NODE_DATABASE, kKEY_PATH, "main"); - cfg->deprecatedClearSection(kSECTION_IMPORT_NODE_DATABASE); - cfg->legacy(kSECTION_DATABASE_PATH, ""); + cfg->overwrite(Sections::kNODE_DATABASE, Keys::kTYPE, "memory"); + cfg->overwrite(Sections::kNODE_DATABASE, Keys::kPATH, "main"); + cfg->deprecatedClearSection(Sections::kIMPORT_NODE_DATABASE); + cfg->legacy(Sections::kDATABASE_PATH, ""); cfg->setupControl(true, true, true); - (*cfg)[kSECTION_SERVER].append(kSECTION_PORT_PEER); - (*cfg)[kSECTION_SERVER].append(kSECTION_PORT_RPC); - (*cfg)[kSECTION_SERVER].append(kSECTION_PORT_WS); + (*cfg)[Sections::kSERVER].append(Sections::kPORT_PEER); + (*cfg)[Sections::kSERVER].append(Sections::kPORT_RPC); + (*cfg)[Sections::kSERVER].append(Sections::kPORT_WS); return cfg; }), std::make_unique(&messages)}; diff --git a/src/test/shamap/common.h b/src/test/shamap/common.h index 069baa2310..5395ec3fdb 100644 --- a/src/test/shamap/common.h +++ b/src/test/shamap/common.h @@ -34,8 +34,8 @@ public: , j_(j) { Section testSection; - testSection.set(kKEY_TYPE, "memory"); - testSection.set(kKEY_PATH, "SHAMap_test"); + testSection.set(Keys::kTYPE, "memory"); + testSection.set(Keys::kPATH, "SHAMap_test"); db_ = NodeStore::Manager::instance().makeDatabase( megabytes(4), scheduler_, 1, testSection, j); } diff --git a/src/tests/libxrpl/helpers/TestFamily.h b/src/tests/libxrpl/helpers/TestFamily.h index 4e12d25c84..bcc2acea1a 100644 --- a/src/tests/libxrpl/helpers/TestFamily.h +++ b/src/tests/libxrpl/helpers/TestFamily.h @@ -39,8 +39,8 @@ public: , j_(j) { Section config; - config.set(kKEY_TYPE, "memory"); - config.set(kKEY_PATH, "TestFamily"); + config.set(Keys::kTYPE, "memory"); + config.set(Keys::kPATH, "TestFamily"); db_ = NodeStore::Manager::instance().makeDatabase(megabytes(4), scheduler_, 1, config, j); } diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 2b855f2153..cb73ac79c3 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -315,13 +315,14 @@ public: // PerfLog must be started before any other threads are launched. , perfLog_( perf::makePerfLog( - perf::setupPerfLog(config_->section(kSECTION_PERF), config_->CONFIG_DIR), + perf::setupPerfLog(config_->section(Sections::kPERF), config_->CONFIG_DIR), *this, logs_->journal("PerfLog"), [this] { signalStop("PerfLog"); })) , txMaster_(*this) - , collectorManager_( - makeCollectorManager(config_->section(kSECTION_INSIGHT), logs_->journal("Collector"))) + , collectorManager_(makeCollectorManager( + config_->section(Sections::kINSIGHT), + logs_->journal("Collector"))) , jobQueue_( std::make_unique( [](std::unique_ptr const& config) { @@ -863,7 +864,7 @@ public: megabytes(config_->getValueFor(SizedItem::BurstSize, std::nullopt)), dummyScheduler, 0, - config_->section(kSECTION_IMPORT_NODE_DATABASE), + config_->section(Sections::kIMPORT_NODE_DATABASE), j); JLOG(j.warn()) << "Starting node import from '" << source->getName() << "' to '" @@ -1219,9 +1220,9 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) } return supported; }(); - Section const& downVoted = config_->section(kSECTION_VETO_AMENDMENTS); + Section const& downVoted = config_->section(Sections::kVETO_AMENDMENTS); - Section const& upVoted = config_->section(kSECTION_AMENDMENTS); + Section const& upVoted = config_->section(Sections::kAMENDMENTS); amendmentTable_ = makeAmendmentTable( *this, @@ -1290,7 +1291,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) nodeIdentity_ = getNodeIdentity(*this, cmdline); - if (!cluster_->load(config().section(kSECTION_CLUSTER_NODES))) + if (!cluster_->load(config().section(Sections::kCLUSTER_NODES))) { JLOG(journal_.fatal()) << "Invalid entry in cluster configuration."; return false; @@ -1304,7 +1305,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) getWalletDB(), "ValidatorManifests", validatorKeys_.manifest, - config().section(kSECTION_VALIDATOR_KEY_REVOCATION).values())) + config().section(Sections::kVALIDATOR_KEY_REVOCATION).values())) { JLOG(journal_.fatal()) << "Invalid configured validator manifest."; return false; @@ -1315,7 +1316,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 - // kSECTION_VALIDATOR_TOKEN or kSECTION_VALIDATION_SEED section. + // Sections::kVALIDATOR_TOKEN or Sections::kVALIDATION_SEED section. // masterKey for the configuration-file specified validator keys std::optional localSigningKey; @@ -1325,8 +1326,8 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) // Setup trusted validators if (!validators_->load( localSigningKey, - config().section(kSECTION_VALIDATORS).values(), - config().section(kSECTION_VALIDATOR_LIST_KEYS).values(), + config().section(Sections::kVALIDATORS).values(), + config().section(Sections::kVALIDATOR_LIST_KEYS).values(), config().VALIDATOR_LIST_THRESHOLD)) { JLOG(journal_.fatal()) << "Invalid entry in validator configuration."; @@ -1334,9 +1335,9 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) } } - if (!validatorSites_->load(config().section(kSECTION_VALIDATOR_LIST_SITES).values())) + if (!validatorSites_->load(config().section(Sections::kVALIDATOR_LIST_SITES).values())) { - JLOG(journal_.fatal()) << "Invalid entry in [" << kSECTION_VALIDATOR_LIST_SITES << "]"; + JLOG(journal_.fatal()) << "Invalid entry in [" << Sections::kVALIDATOR_LIST_SITES << "]"; return false; } @@ -1434,7 +1435,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) // // Execute start up rpc commands. // - for (auto const& cmd : config_->section(kSECTION_RPC_STARTUP).lines()) + for (auto const& cmd : config_->section(Sections::kRPC_STARTUP).lines()) { json::Reader jrReader; json::Value jvCommand; @@ -1442,7 +1443,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) if (!jrReader.parse(cmd, jvCommand)) { JLOG(journal_.fatal()) - << "Couldn't parse entry in [" << kSECTION_RPC_STARTUP << "]: '" << cmd; + << "Couldn't parse entry in [" << Sections::kRPC_STARTUP << "]: '" << cmd; } if (!config_->quiet()) @@ -1498,7 +1499,7 @@ ApplicationImp::start(bool withTimers) overlay_->start(); if (grpcServer_->start()) - fixConfigPorts(*config_, {{kSECTION_PORT_GRPC, grpcServer_->getEndpoint()}}); + fixConfigPorts(*config_, {{Sections::kPORT_GRPC, grpcServer_->getEndpoint()}}); ledgerCleaner_->start(); perfLog_->start(); @@ -2166,12 +2167,12 @@ fixConfigPorts(Config& config, Endpoints const& endpoints) continue; auto& section = config[name]; - auto const optPort = section.get(kKEY_PORT); + auto const optPort = section.get(Keys::kPORT); if (optPort) { std::uint16_t const port = beast::lexicalCast(*optPort); if (port == 0u) - section.set(kKEY_PORT, std::to_string(ep.port())); + section.set(Keys::kPORT, std::to_string(ep.port())); } } } diff --git a/src/xrpld/app/main/CollectorManager.cpp b/src/xrpld/app/main/CollectorManager.cpp index 3a11eee9c0..82ab1b84e3 100644 --- a/src/xrpld/app/main/CollectorManager.cpp +++ b/src/xrpld/app/main/CollectorManager.cpp @@ -25,13 +25,13 @@ public: CollectorManagerImp(Section const& params, beast::Journal journal) : journal_(journal) { - std::string const& server = get(params, kKEY_SERVER); + std::string const& server = get(params, Keys::kSERVER); if (server == "statsd") { beast::IP::Endpoint const address( - beast::IP::Endpoint::fromString(get(params, kKEY_ADDRESS))); - std::string const& prefix(get(params, kKEY_PREFIX)); + beast::IP::Endpoint::fromString(get(params, Keys::kADDRESS))); + std::string const& prefix(get(params, Keys::kPREFIX)); collector_ = beast::insight::StatsDCollector::make(address, prefix, journal); } diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 9b8bba1fcb..ee533aaf7b 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -334,15 +334,15 @@ GRPCServerImpl::GRPCServerImpl(Application& app) : app_(app), journal_(app_.getJournal("gRPC Server")) { // if present, get endpoint from config - if (app_.config().exists(kSECTION_PORT_GRPC)) + if (app_.config().exists(Sections::kPORT_GRPC)) { - Section const& section = app_.config().section(kSECTION_PORT_GRPC); + Section const& section = app_.config().section(Sections::kPORT_GRPC); - auto const optIp = section.get(kKEY_IP); + auto const optIp = section.get(Keys::kIP); if (!optIp) return; - auto const optPort = section.get(kKEY_PORT); + auto const optPort = section.get(Keys::kPORT); if (!optPort) return; try @@ -360,7 +360,7 @@ GRPCServerImpl::GRPCServerImpl(Application& app) Throw("Error setting grpc server address"); } - auto const optSecureGateway = section.get(kKEY_SECURE_GATEWAY); + auto const optSecureGateway = section.get(Keys::kSECURE_GATEWAY); if (optSecureGateway) { try @@ -390,10 +390,10 @@ GRPCServerImpl::GRPCServerImpl(Application& app) } // Read TLS certificate configuration (optional) - sslCertPath_ = section.get(kKEY_SSL_CERT); - sslKeyPath_ = section.get(kKEY_SSL_KEY); - sslCertChainPath_ = section.get(kKEY_SSL_CERT_CHAIN); - sslClientCAPath_ = section.get(kKEY_SSL_CLIENT_CA); + sslCertPath_ = section.get(Keys::kSSL_CERT); + sslKeyPath_ = section.get(Keys::kSSL_KEY); + sslCertChainPath_ = section.get(Keys::kSSL_CERT_CHAIN); + sslClientCAPath_ = section.get(Keys::kSSL_CLIENT_CA); // If cert or key is specified, both must be specified if (sslCertPath_.has_value() || sslKeyPath_.has_value()) diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index 5bb84c00a9..8b64c6b7ea 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -362,10 +362,10 @@ run(int argc, char** argv) std::string importText; { importText += "Import an existing node database (specified in the ["; - importText += kSECTION_IMPORT_NODE_DATABASE; + importText += Sections::kIMPORT_NODE_DATABASE; importText += "] configuration file section) into the current "; importText += "node database (specified in the ["; - importText += kSECTION_NODE_DATABASE; + importText += Sections::kNODE_DATABASE; importText += "] configuration file section)."; } diff --git a/src/xrpld/app/main/NodeIdentity.cpp b/src/xrpld/app/main/NodeIdentity.cpp index f6c908fccf..c777753f32 100644 --- a/src/xrpld/app/main/NodeIdentity.cpp +++ b/src/xrpld/app/main/NodeIdentity.cpp @@ -31,13 +31,13 @@ getNodeIdentity(Application& app, boost::program_options::variables_map const& c if (!seed) Throw("Invalid 'nodeid' in command line"); } - else if (app.config().exists(kSECTION_NODE_SEED)) + else if (app.config().exists(Sections::kNODE_SEED)) { - seed = parseBase58(app.config().section(kSECTION_NODE_SEED).lines().front()); + seed = parseBase58(app.config().section(Sections::kNODE_SEED).lines().front()); if (!seed) Throw( - std::string("Invalid [") + kSECTION_NODE_SEED + "] in configuration file"); + std::string("Invalid [") + Sections::kNODE_SEED + "] in configuration file"); } if (seed) diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index f063e4fb5c..cad28182db 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -313,7 +313,7 @@ public: , consensus_( registry_.get().getApp(), makeFeeVote( - setupFeeVote(registry_.get().getApp().config().section(kSECTION_VOTING)), + setupFeeVote(registry_.get().getApp().config().section(Sections::kVOTING)), registry_.get().getJournal("FeeVote")), ledgerMaster, *localTX_, @@ -2972,11 +2972,12 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) } } - if (registry_.get().getApp().config().exists(kSECTION_PORT_GRPC)) + if (registry_.get().getApp().config().exists(Sections::kPORT_GRPC)) { - auto const& grpcSection = registry_.get().getApp().config().section(kSECTION_PORT_GRPC); - auto const optPort = grpcSection.get(kKEY_PORT); - if (optPort && grpcSection.get(kKEY_IP)) + auto const& grpcSection = + registry_.get().getApp().config().section(Sections::kPORT_GRPC); + auto const optPort = grpcSection.get(Keys::kPORT); + if (optPort && grpcSection.get(Keys::kIP)) { auto& jv = ports.append(json::Value(json::ObjectValue)); jv[jss::port] = *optPort; diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index f97dcd2486..577d2e5089 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -100,45 +100,45 @@ SHAMapStoreImp::SHAMapStoreImp( { Config& config{app.config()}; - Section& section{config.section(kSECTION_NODE_DATABASE)}; + Section& section{config.section(Sections::kNODE_DATABASE)}; if (section.empty()) { Throw( - std::string("Missing [") + kSECTION_NODE_DATABASE + "] entry in configuration file"); + std::string("Missing [") + Sections::kNODE_DATABASE + "] entry in configuration file"); } // RocksDB only. Use sensible defaults if no values specified. - if (boost::iequals(get(section, kKEY_TYPE), "RocksDB")) + if (boost::iequals(get(section, Keys::kTYPE), "RocksDB")) { - if (!section.exists(kKEY_CACHE_MB)) + if (!section.exists(Keys::kCACHE_MB)) { section.set( - kKEY_CACHE_MB, std::to_string(config.getValueFor(SizedItem::HashNodeDbCache))); + Keys::kCACHE_MB, std::to_string(config.getValueFor(SizedItem::HashNodeDbCache))); } - if (!section.exists(kKEY_FILTER_BITS) && (config.NODE_SIZE >= 2)) - section.set(kKEY_FILTER_BITS, "10"); + if (!section.exists(Keys::kFILTER_BITS) && (config.NODE_SIZE >= 2)) + section.set(Keys::kFILTER_BITS, "10"); } - getIfExists(section, kKEY_ONLINE_DELETE, deleteInterval_); + getIfExists(section, Keys::kONLINE_DELETE, deleteInterval_); if (deleteInterval_ != 0u) { // Configuration that affects the behavior of online delete - getIfExists(section, kKEY_DELETE_BATCH, deleteBatch_); + getIfExists(section, Keys::kDELETE_BATCH, deleteBatch_); std::uint32_t temp = 0; - if (getIfExists(section, kKEY_BACK_OFF_MILLISECONDS, temp) || + if (getIfExists(section, Keys::kBACK_OFF_MILLISECONDS, temp) || // Included for backward compatibility with an undocumented setting - getIfExists(section, kKEY_BACK_OFF, temp)) + getIfExists(section, Keys::kBACK_OFF, temp)) { backOff_ = std::chrono::milliseconds{temp}; } - if (getIfExists(section, kKEY_AGE_THRESHOLD_SECONDS, temp)) + if (getIfExists(section, Keys::kAGE_THRESHOLD_SECONDS, temp)) ageThreshold_ = std::chrono::seconds{temp}; - if (getIfExists(section, kKEY_RECOVERY_WAIT_SECONDS, temp)) + if (getIfExists(section, Keys::kRECOVERY_WAIT_SECONDS, temp)) recoveryWaitTime_ = std::chrono::seconds{temp}; - getIfExists(section, kKEY_ADVISORY_DELETE, advisoryDelete_); + getIfExists(section, Keys::kADVISORY_DELETE, advisoryDelete_); auto const minInterval = config.standalone() ? kMINIMUM_DELETION_INTERVAL_SA : kMINIMUM_DELETION_INTERVAL; @@ -164,7 +164,7 @@ SHAMapStoreImp::SHAMapStoreImp( std::unique_ptr SHAMapStoreImp::makeNodeStore(int readThreads) { - auto nscfg = app_.config().section(kSECTION_NODE_DATABASE); + auto nscfg = app_.config().section(Sections::kNODE_DATABASE); std::unique_ptr db; if (deleteInterval_ != 0u) @@ -367,8 +367,8 @@ SHAMapStoreImp::run() void SHAMapStoreImp::dbPaths() { - Section const section{app_.config().section(kSECTION_NODE_DATABASE)}; - boost::filesystem::path dbPath = get(section, kKEY_PATH); + Section const section{app_.config().section(Sections::kNODE_DATABASE)}; + boost::filesystem::path dbPath = get(section, Keys::kPATH); if (boost::filesystem::exists(dbPath)) { @@ -433,7 +433,7 @@ SHAMapStoreImp::dbPaths() (!archiveDbExists && !state.archiveDb.empty()) || (writableDbExists != archiveDbExists) || state.writableDb.empty() != state.archiveDb.empty()) { - boost::filesystem::path stateDbPathName = app_.config().legacy(kSECTION_DATABASE_PATH); + boost::filesystem::path stateDbPathName = app_.config().legacy(Sections::kDATABASE_PATH); stateDbPathName /= dbName_; stateDbPathName += "*"; @@ -445,7 +445,7 @@ SHAMapStoreImp::dbPaths() << "The existing data is in a corrupted state.\n" << "To resume operation, remove the files matching " << stateDbPathName.string() << " and contents of the directory " - << get(section, kKEY_PATH) << '\n' + << get(section, Keys::kPATH) << '\n' << "Optionally, you can move those files to another\n" << "location if you wish to analyze or back up the data.\n" << "However, there is no guarantee that the data in its\n" @@ -462,7 +462,7 @@ SHAMapStoreImp::dbPaths() std::unique_ptr SHAMapStoreImp::makeBackendRotating(std::string path) { - Section section{app_.config().section(kSECTION_NODE_DATABASE)}; + Section section{app_.config().section(Sections::kNODE_DATABASE)}; boost::filesystem::path newPath; if (!path.empty()) @@ -471,12 +471,12 @@ SHAMapStoreImp::makeBackendRotating(std::string path) } else { - boost::filesystem::path p = get(section, kKEY_PATH); + boost::filesystem::path p = get(section, Keys::kPATH); p /= dbPrefix_; p += ".%%%%"; newPath = boost::filesystem::unique_path(p); } - section.set(kKEY_PATH, newPath.string()); + section.set(Keys::kPATH, newPath.string()); auto backend{NodeStore::Manager::instance().makeBackend( section, diff --git a/src/xrpld/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h index 7cff09b436..a1fb8fc3ee 100644 --- a/src/xrpld/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -233,7 +233,7 @@ class ValidatorList std::optional localPubKey_; // The below variable contains the Publisher list specified in the local - // config file under the title of kSECTION_VALIDATORS or [validators]. + // config file under the title of Sections::kVALIDATORS or [validators]. // This list is not associated with the masterKey of any publisher. // Apropos PublisherListCollection fields, localPublisherList does not diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index bbf26ebfbf..dbd8127e19 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -1871,7 +1871,7 @@ TxQ::Setup setupTxQ(Config const& config) { TxQ::Setup setup; - auto const& section = config.section(kSECTION_TRANSACTION_QUEUE); + auto const& section = config.section(Sections::kTRANSACTION_QUEUE); set(setup.ledgersInQueue, "ledgers_in_queue", section); set(setup.queueSizeMin, "minimum_queue_size", section); set(setup.retrySequencePercent, "retry_sequence_percent", section); diff --git a/src/xrpld/app/misc/detail/ValidatorKeys.cpp b/src/xrpld/app/misc/detail/ValidatorKeys.cpp index 8063fcf405..ed86d4bffa 100644 --- a/src/xrpld/app/misc/detail/ValidatorKeys.cpp +++ b/src/xrpld/app/misc/detail/ValidatorKeys.cpp @@ -17,18 +17,18 @@ namespace xrpl { ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j) { - if (config.exists(kSECTION_VALIDATOR_TOKEN) && config.exists(kSECTION_VALIDATION_SEED)) + if (config.exists(Sections::kVALIDATOR_TOKEN) && config.exists(Sections::kVALIDATION_SEED)) { configInvalid_ = true; - JLOG(j.fatal()) << "Cannot specify both [" << kSECTION_VALIDATION_SEED << "] and [" - << kSECTION_VALIDATOR_TOKEN << "]"; + JLOG(j.fatal()) << "Cannot specify both [" << Sections::kVALIDATION_SEED << "] and [" + << Sections::kVALIDATOR_TOKEN << "]"; return; } - if (config.exists(kSECTION_VALIDATOR_TOKEN)) + if (config.exists(Sections::kVALIDATOR_TOKEN)) { // token is non-const so it can be moved from - if (auto token = loadValidatorToken(config.section(kSECTION_VALIDATOR_TOKEN).lines())) + if (auto token = loadValidatorToken(config.section(Sections::kVALIDATOR_TOKEN).lines())) { auto const pk = derivePublicKey(KeyType::Secp256k1, token->validationSecret); auto const m = deserializeManifest(base64Decode(token->manifest)); @@ -36,7 +36,7 @@ ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j) if (!m || pk != m->signingKey) { configInvalid_ = true; - JLOG(j.fatal()) << "Invalid token specified in [" << kSECTION_VALIDATOR_TOKEN + JLOG(j.fatal()) << "Invalid token specified in [" << Sections::kVALIDATOR_TOKEN << "]"; } else @@ -50,17 +50,17 @@ ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j) else { configInvalid_ = true; - JLOG(j.fatal()) << "Invalid token specified in [" << kSECTION_VALIDATOR_TOKEN << "]"; + JLOG(j.fatal()) << "Invalid token specified in [" << Sections::kVALIDATOR_TOKEN << "]"; } } - else if (config.exists(kSECTION_VALIDATION_SEED)) + else if (config.exists(Sections::kVALIDATION_SEED)) { auto const seed = - parseBase58(config.section(kSECTION_VALIDATION_SEED).lines().front()); + parseBase58(config.section(Sections::kVALIDATION_SEED).lines().front()); if (!seed) { configInvalid_ = true; - JLOG(j.fatal()) << "Invalid seed specified in [" << kSECTION_VALIDATION_SEED << "]"; + JLOG(j.fatal()) << "Invalid seed specified in [" << Sections::kVALIDATION_SEED << "]"; } else { diff --git a/src/xrpld/app/misc/detail/setup_HashRouter.cpp b/src/xrpld/app/misc/detail/setup_HashRouter.cpp index 75a23218e6..98da63fe88 100644 --- a/src/xrpld/app/misc/detail/setup_HashRouter.cpp +++ b/src/xrpld/app/misc/detail/setup_HashRouter.cpp @@ -18,7 +18,7 @@ setupHashRouter(Config const& config) using namespace std::chrono; HashRouter::Setup setup; - auto const& section = config.section(kSECTION_HASHROUTER); + auto const& section = config.section(Sections::kHASHROUTER); std::int32_t tmp{}; diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 27d1d736ce..d8f0abf49f 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -1293,7 +1293,7 @@ bool dbHasSpace(soci::session& session, Config const& config, beast::Journal j) { boost::filesystem::space_info const space = - boost::filesystem::space(config.legacy(kSECTION_DATABASE_PATH)); + boost::filesystem::space(config.legacy(Sections::kDATABASE_PATH)); if (space.available < megabytes(512)) { diff --git a/src/xrpld/core/detail/Config.cpp b/src/xrpld/core/detail/Config.cpp index 3f5a58f14f..c29db59cba 100644 --- a/src/xrpld/core/detail/Config.cpp +++ b/src/xrpld/core/detail/Config.cpp @@ -383,7 +383,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand load(); { // load() may have set a new value for the dataDir - std::string const dbPath(legacy(kSECTION_DATABASE_PATH)); + std::string const dbPath(legacy(Sections::kDATABASE_PATH)); if (!dbPath.empty()) { dataDir = boost::filesystem::path(dbPath); @@ -402,7 +402,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand if (ec) Throw(boost::str(boost::format("Can not create %s") % dataDir)); - legacy(kSECTION_DATABASE_PATH, boost::filesystem::absolute(dataDir).string()); + legacy(Sections::kDATABASE_PATH, boost::filesystem::absolute(dataDir).string()); } HTTPClient::initializeSSLContext( @@ -411,11 +411,11 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand if (RUN_STANDALONE_) LEDGER_HISTORY = 0; - Section const ledgerTxTablesSection = section(kSECTION_LEDGER_TX_TABLES); - getIfExists(ledgerTxTablesSection, kKEY_USE_TX_TABLES, USE_TX_TABLES_); + Section const ledgerTxTablesSection = section(Sections::kLEDGER_TX_TABLES); + getIfExists(ledgerTxTablesSection, Keys::kUSE_TX_TABLES, USE_TX_TABLES_); - Section const& nodeDbSection{section(kSECTION_NODE_DATABASE)}; - getIfExists(nodeDbSection, kKEY_FAST_LOAD, FAST_LOAD); + Section const& nodeDbSection{section(Sections::kNODE_DATABASE)}; + getIfExists(nodeDbSection, Keys::kFAST_LOAD, FAST_LOAD); } // 0 ports are allowed for unit tests, but still not allowed to be present in @@ -423,16 +423,16 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand static void checkZeroPorts(Config const& config) { - if (!config.exists(kSECTION_SERVER)) + if (!config.exists(Sections::kSERVER)) return; - for (auto const& name : config.section(kSECTION_SERVER).values()) + for (auto const& name : config.section(Sections::kSERVER).values()) { if (!config.exists(name)) return; auto const& section = config[name]; - auto const optResult = section.get(kKEY_PORT); + auto const optResult = section.get(Keys::kPORT); if (optResult) { auto const port = beast::lexicalCast(*optResult); @@ -476,10 +476,10 @@ Config::loadFromString(std::string const& fileContents) build(secConfig); - if (auto s = getIniFileSection(secConfig, kSECTION_IPS)) + if (auto s = getIniFileSection(secConfig, Sections::kIPS)) IPS = *s; - if (auto s = getIniFileSection(secConfig, kSECTION_IPS_FIXED)) + if (auto s = getIniFileSection(secConfig, Sections::kIPS_FIXED)) IPS_FIXED = *s; // if the user has specified ip:port then replace : with a space. @@ -506,16 +506,16 @@ Config::loadFromString(std::string const& fileContents) { std::string dbPath; - if (getSingleSection(secConfig, kSECTION_DATABASE_PATH, dbPath, j_)) + if (getSingleSection(secConfig, Sections::kDATABASE_PATH, dbPath, j_)) { boost::filesystem::path const p(dbPath); - legacy(kSECTION_DATABASE_PATH, boost::filesystem::absolute(p).string()); + legacy(Sections::kDATABASE_PATH, boost::filesystem::absolute(p).string()); } } std::string strTemp; - if (getSingleSection(secConfig, kSECTION_NETWORK_ID, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kNETWORK_ID, strTemp, j_)) { if (strTemp == "main") { @@ -535,35 +535,35 @@ Config::loadFromString(std::string const& fileContents) } } - if (getSingleSection(secConfig, kSECTION_PEER_PRIVATE, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPEER_PRIVATE, strTemp, j_)) PEER_PRIVATE = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_PEERS_MAX, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPEERS_MAX, strTemp, j_)) { PEERS_MAX = beast::lexicalCastThrow(strTemp); } else { std::optional peersInMax{}; - if (getSingleSection(secConfig, kSECTION_PEERS_IN_MAX, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPEERS_IN_MAX, strTemp, j_)) { peersInMax = beast::lexicalCastThrow(strTemp); if (*peersInMax > 1000) { Throw( - std::string("Invalid value specified in [") + kSECTION_PEERS_IN_MAX + + std::string("Invalid value specified in [") + Sections::kPEERS_IN_MAX + "] section; the value must be less or equal than 1000"); } } std::optional peersOutMax{}; - if (getSingleSection(secConfig, kSECTION_PEERS_OUT_MAX, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPEERS_OUT_MAX, strTemp, j_)) { peersOutMax = beast::lexicalCastThrow(strTemp); if (*peersOutMax < 10 || *peersOutMax > 1000) { Throw( - std::string("Invalid value specified in [") + kSECTION_PEERS_OUT_MAX + + std::string("Invalid value specified in [") + Sections::kPEERS_OUT_MAX + "] section; the value must be in range 10-1000"); } } @@ -572,8 +572,8 @@ Config::loadFromString(std::string const& fileContents) if ((peersInMax && !peersOutMax) || (peersOutMax && !peersInMax)) { Throw( - std::string("Both sections [") + kSECTION_PEERS_IN_MAX + "]" + "and [" + - kSECTION_PEERS_OUT_MAX + "] must be configured"); + std::string("Both sections [") + Sections::kPEERS_IN_MAX + "]" + "and [" + + Sections::kPEERS_OUT_MAX + "] must be configured"); } if (peersInMax && peersOutMax) @@ -583,7 +583,7 @@ Config::loadFromString(std::string const& fileContents) } } - if (getSingleSection(secConfig, kSECTION_NODE_SIZE, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kNODE_SIZE, strTemp, j_)) { if (boost::iequals(strTemp, "tiny")) { @@ -611,19 +611,19 @@ Config::loadFromString(std::string const& fileContents) } } - if (getSingleSection(secConfig, kSECTION_SIGNING_SUPPORT, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kSIGNING_SUPPORT, strTemp, j_)) signingEnabled_ = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_ELB_SUPPORT, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kELB_SUPPORT, strTemp, j_)) ELB_SUPPORT = beast::lexicalCastThrow(strTemp); - getSingleSection(secConfig, kSECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE, j_); - getSingleSection(secConfig, kSECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR, j_); + getSingleSection(secConfig, Sections::kSSL_VERIFY_FILE, SSL_VERIFY_FILE, j_); + getSingleSection(secConfig, Sections::kSSL_VERIFY_DIR, SSL_VERIFY_DIR, j_); - if (getSingleSection(secConfig, kSECTION_SSL_VERIFY, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kSSL_VERIFY, strTemp, j_)) SSL_VERIFY = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_RELAY_VALIDATIONS, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kRELAY_VALIDATIONS, strTemp, j_)) { if (boost::iequals(strTemp, "all")) { @@ -640,12 +640,12 @@ Config::loadFromString(std::string const& fileContents) else { Throw( - std::string("Invalid value specified in [") + kSECTION_RELAY_VALIDATIONS + + std::string("Invalid value specified in [") + Sections::kRELAY_VALIDATIONS + "] section"); } } - if (getSingleSection(secConfig, kSECTION_RELAY_PROPOSALS, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kRELAY_PROPOSALS, strTemp, j_)) { if (boost::iequals(strTemp, "all")) { @@ -662,29 +662,29 @@ Config::loadFromString(std::string const& fileContents) else { Throw( - std::string("Invalid value specified in [") + kSECTION_RELAY_PROPOSALS + + std::string("Invalid value specified in [") + Sections::kRELAY_PROPOSALS + "] section"); } } - if (exists(kSECTION_VALIDATION_SEED) && exists(kSECTION_VALIDATOR_TOKEN)) + if (exists(Sections::kVALIDATION_SEED) && exists(Sections::kVALIDATOR_TOKEN)) { Throw( - std::string("Cannot have both [") + kSECTION_VALIDATION_SEED + "] and [" + - kSECTION_VALIDATOR_TOKEN + "] config sections"); + std::string("Cannot have both [") + Sections::kVALIDATION_SEED + "] and [" + + Sections::kVALIDATOR_TOKEN + "] config sections"); } - if (getSingleSection(secConfig, kSECTION_NETWORK_QUORUM, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kNETWORK_QUORUM, strTemp, j_)) NETWORK_QUORUM = beast::lexicalCastThrow(strTemp); - FEES = setupFeeVote(section(kSECTION_VOTING)); + FEES = setupFeeVote(section(Sections::kVOTING)); /* [fee_default] is documented in the example config files as useful for * things like offline transaction signing. Until that's completely * deprecated, allow it to override the [voting] section. */ - if (getSingleSection(secConfig, kSECTION_FEE_DEFAULT, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kFEE_DEFAULT, strTemp, j_)) FEES.reference_fee = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_LEDGER_HISTORY, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kLEDGER_HISTORY, strTemp, j_)) { if (boost::iequals(strTemp, "full")) { @@ -700,7 +700,7 @@ Config::loadFromString(std::string const& fileContents) } } - if (getSingleSection(secConfig, kSECTION_FETCH_DEPTH, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kFETCH_DEPTH, strTemp, j_)) { if (boost::iequals(strTemp, "none")) { @@ -720,78 +720,78 @@ Config::loadFromString(std::string const& fileContents) // By default, validators don't have pathfinding enabled, unless it is // explicitly requested by the server's admin. - if (exists(kSECTION_VALIDATION_SEED) || exists(kSECTION_VALIDATOR_TOKEN)) + if (exists(Sections::kVALIDATION_SEED) || exists(Sections::kVALIDATOR_TOKEN)) PATH_SEARCH_MAX = 0; - if (getSingleSection(secConfig, kSECTION_PATH_SEARCH_OLD, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPATH_SEARCH_OLD, strTemp, j_)) PATH_SEARCH_OLD = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_PATH_SEARCH, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPATH_SEARCH, strTemp, j_)) PATH_SEARCH = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_PATH_SEARCH_FAST, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPATH_SEARCH_FAST, strTemp, j_)) PATH_SEARCH_FAST = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_PATH_SEARCH_MAX, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPATH_SEARCH_MAX, strTemp, j_)) PATH_SEARCH_MAX = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_DEBUG_LOGFILE, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kDEBUG_LOGFILE, strTemp, j_)) DEBUG_LOGFILE_ = strTemp; - if (getSingleSection(secConfig, kSECTION_SWEEP_INTERVAL, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kSWEEP_INTERVAL, strTemp, j_)) { SWEEP_INTERVAL = beast::lexicalCastThrow(strTemp); if (SWEEP_INTERVAL < 10 || SWEEP_INTERVAL > 600) { Throw( - std::string("Invalid ") + kSECTION_SWEEP_INTERVAL + + std::string("Invalid ") + Sections::kSWEEP_INTERVAL + ": must be between 10 and 600 inclusive"); } } - if (getSingleSection(secConfig, kSECTION_WORKERS, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kWORKERS, strTemp, j_)) { WORKERS = beast::lexicalCastThrow(strTemp); if (WORKERS < 1 || WORKERS > 1024) { Throw( - std::string("Invalid ") + kSECTION_WORKERS + + std::string("Invalid ") + Sections::kWORKERS + ": must be between 1 and 1024 inclusive."); } } - if (getSingleSection(secConfig, kSECTION_IO_WORKERS, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kIO_WORKERS, strTemp, j_)) { IO_WORKERS = beast::lexicalCastThrow(strTemp); if (IO_WORKERS < 1 || IO_WORKERS > 1024) { Throw( - std::string("Invalid ") + kSECTION_IO_WORKERS + + std::string("Invalid ") + Sections::kIO_WORKERS + ": must be between 1 and 1024 inclusive."); } } - if (getSingleSection(secConfig, kSECTION_PREFETCH_WORKERS, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kPREFETCH_WORKERS, strTemp, j_)) { PREFETCH_WORKERS = beast::lexicalCastThrow(strTemp); if (PREFETCH_WORKERS < 1 || PREFETCH_WORKERS > 1024) { Throw( - std::string("Invalid ") + kSECTION_PREFETCH_WORKERS + + std::string("Invalid ") + Sections::kPREFETCH_WORKERS + ": must be between 1 and 1024 inclusive."); } } - if (getSingleSection(secConfig, kSECTION_COMPRESSION, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kCOMPRESSION, strTemp, j_)) COMPRESSION = beast::lexicalCastThrow(strTemp); - if (getSingleSection(secConfig, kSECTION_LEDGER_REPLAY, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kLEDGER_REPLAY, strTemp, j_)) LEDGER_REPLAY = beast::lexicalCastThrow(strTemp); - if (exists(kSECTION_REDUCE_RELAY)) + if (exists(Sections::kREDUCE_RELAY)) { - auto sec = section(kSECTION_REDUCE_RELAY); + auto sec = section(Sections::kREDUCE_RELAY); ///////////////////// !!TEMPORARY CODE BLOCK!! //////////////////////// // vp_enable config option is deprecated by vp_base_squelch_enable // @@ -799,23 +799,23 @@ Config::loadFromString(std::string const& fileContents) // is the default algorithm, it must be replaced with: // // VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = // // sec.value_or("vp_base_squelch_enable", true); // - if (sec.exists(kKEY_VP_BASE_SQUELCH_ENABLE) && sec.exists(kKEY_VP_ENABLE)) + if (sec.exists(Keys::kVP_BASE_SQUELCH_ENABLE) && sec.exists(Keys::kVP_ENABLE)) { Throw( - std::string("Invalid ") + kSECTION_REDUCE_RELAY + + std::string("Invalid ") + Sections::kREDUCE_RELAY + " cannot specify both vp_base_squelch_enable and vp_enable " "options. " "vp_enable was deprecated and replaced by " "vp_base_squelch_enable"); } - if (sec.exists(kKEY_VP_BASE_SQUELCH_ENABLE)) + if (sec.exists(Keys::kVP_BASE_SQUELCH_ENABLE)) { - VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.valueOr(kKEY_VP_BASE_SQUELCH_ENABLE, false); + VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.valueOr(Keys::kVP_BASE_SQUELCH_ENABLE, false); } - else if (sec.exists(kKEY_VP_ENABLE)) + else if (sec.exists(Keys::kVP_ENABLE)) { - VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.valueOr(kKEY_VP_ENABLE, false); + VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE = sec.valueOr(Keys::kVP_ENABLE, false); } else { @@ -828,94 +828,94 @@ Config::loadFromString(std::string const& fileContents) // validator messages. The config must be removed once squelching is // // made the default routing algorithm. // VP_REDUCE_RELAY_SQUELCH_MAX_SELECTED_PEERS = - sec.valueOr(kKEY_VP_BASE_SQUELCH_MAX_SELECTED_PEERS, 5); + sec.valueOr(Keys::kVP_BASE_SQUELCH_MAX_SELECTED_PEERS, 5); if (VP_REDUCE_RELAY_SQUELCH_MAX_SELECTED_PEERS < 3) { Throw( - std::string("Invalid ") + kSECTION_REDUCE_RELAY + + std::string("Invalid ") + Sections::kREDUCE_RELAY + " vp_base_squelch_max_selected_peers must be " "greater than or equal to 3"); } ///////////////// !!END OF TEMPORARY CODE BLOCK!! ///////////////////// - TX_REDUCE_RELAY_ENABLE = sec.valueOr(kKEY_TX_ENABLE, false); - TX_REDUCE_RELAY_METRICS = sec.valueOr(kKEY_TX_METRICS, false); - TX_REDUCE_RELAY_MIN_PEERS = sec.valueOr(kKEY_TX_MIN_PEERS, 20); - TX_RELAY_PERCENTAGE = sec.valueOr(kKEY_TX_RELAY_PERCENTAGE, 25); + TX_REDUCE_RELAY_ENABLE = sec.valueOr(Keys::kTX_ENABLE, false); + TX_REDUCE_RELAY_METRICS = sec.valueOr(Keys::kTX_METRICS, false); + TX_REDUCE_RELAY_MIN_PEERS = sec.valueOr(Keys::kTX_MIN_PEERS, 20); + TX_RELAY_PERCENTAGE = sec.valueOr(Keys::kTX_RELAY_PERCENTAGE, 25); if (TX_RELAY_PERCENTAGE < 10 || TX_RELAY_PERCENTAGE > 100 || TX_REDUCE_RELAY_MIN_PEERS < 10) { Throw( - std::string("Invalid ") + kSECTION_REDUCE_RELAY + + std::string("Invalid ") + Sections::kREDUCE_RELAY + ", tx_min_peers must be greater than or equal to 10" ", tx_relay_percentage must be greater than or equal to 10 " "and less than or equal to 100"); } } - if (getSingleSection(secConfig, kSECTION_MAX_TRANSACTIONS, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kMAX_TRANSACTIONS, strTemp, j_)) { MAX_TRANSACTIONS = std::clamp(beast::lexicalCastThrow(strTemp), kMIN_JOB_QUEUE_TX, kMAX_JOB_QUEUE_TX); } - if (getSingleSection(secConfig, kSECTION_SERVER_DOMAIN, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kSERVER_DOMAIN, strTemp, j_)) { if (!isProperlyFormedTomlDomain(strTemp)) { Throw( - std::string("Invalid ") + kSECTION_SERVER_DOMAIN + + std::string("Invalid ") + Sections::kSERVER_DOMAIN + ": the domain name does not appear to meet the requirements."); } SERVER_DOMAIN = strTemp; } - if (exists(kSECTION_OVERLAY)) + if (exists(Sections::kOVERLAY)) { - auto const sec = section(kSECTION_OVERLAY); + auto const sec = section(Sections::kOVERLAY); using namespace std::chrono; try { - if (auto val = sec.get(kKEY_MAX_UNKNOWN_TIME)) + if (auto val = sec.get(Keys::kMAX_UNKNOWN_TIME)) MAX_UNKNOWN_TIME = seconds{beast::lexicalCastThrow(*val)}; } catch (...) { Throw( - std::string("Invalid value 'max_unknown_time' in ") + kSECTION_OVERLAY + + std::string("Invalid value 'max_unknown_time' in ") + Sections::kOVERLAY + ": must be of the form '' representing seconds."); } if (MAX_UNKNOWN_TIME < seconds{300} || MAX_UNKNOWN_TIME > seconds{1800}) { Throw( - std::string("Invalid value 'max_unknown_time' in ") + kSECTION_OVERLAY + + std::string("Invalid value 'max_unknown_time' in ") + Sections::kOVERLAY + ": the time must be between 300 and 1800 seconds, inclusive."); } try { - if (auto val = sec.get(kKEY_MAX_DIVERGED_TIME)) + if (auto val = sec.get(Keys::kMAX_DIVERGED_TIME)) MAX_DIVERGED_TIME = seconds{beast::lexicalCastThrow(*val)}; } catch (...) { Throw( - std::string("Invalid value 'max_diverged_time' in ") + kSECTION_OVERLAY + + std::string("Invalid value 'max_diverged_time' in ") + Sections::kOVERLAY + ": must be of the form '' representing seconds."); } if (MAX_DIVERGED_TIME < seconds{60} || MAX_DIVERGED_TIME > seconds{900}) { Throw( - std::string("Invalid value 'max_diverged_time' in ") + kSECTION_OVERLAY + + std::string("Invalid value 'max_diverged_time' in ") + Sections::kOVERLAY + ": the time must be between 60 and 900 seconds, inclusive."); } } - if (getSingleSection(secConfig, kSECTION_AMENDMENT_MAJORITY_TIME, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kAMENDMENT_MAJORITY_TIME, strTemp, j_)) { using namespace std::chrono; boost::regex const re("^\\s*(\\d+)\\s*(minutes|hours|days|weeks)\\s*(\\s+.*)?$"); @@ -923,7 +923,7 @@ Config::loadFromString(std::string const& fileContents) if (!boost::regex_match(strTemp, match, re)) { Throw( - std::string("Invalid ") + kSECTION_AMENDMENT_MAJORITY_TIME + + std::string("Invalid ") + Sections::kAMENDMENT_MAJORITY_TIME + ", must be: [0-9]+ [minutes|hours|days|weeks]"); } @@ -949,13 +949,13 @@ Config::loadFromString(std::string const& fileContents) if (AMENDMENT_MAJORITY_TIME < minutes(15)) { Throw( - std::string("Invalid ") + kSECTION_AMENDMENT_MAJORITY_TIME + + std::string("Invalid ") + Sections::kAMENDMENT_MAJORITY_TIME + ", the minimum amount of time an amendment must hold a " "majority is 15 minutes"); } } - if (getSingleSection(secConfig, kSECTION_BETA_RPC_API, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kBETA_RPC_API, strTemp, j_)) BETA_RPC_API = beast::lexicalCastThrow(strTemp); // Do not load trusted validator configuration for standalone mode @@ -971,14 +971,14 @@ Config::loadFromString(std::string const& fileContents) // if we can't find it. boost::filesystem::path validatorsFile; - if (getSingleSection(secConfig, kSECTION_VALIDATORS_FILE, strTemp, j_)) + if (getSingleSection(secConfig, Sections::kVALIDATORS_FILE, strTemp, j_)) { validatorsFile = strTemp; if (validatorsFile.empty()) { Throw( - std::string("Invalid path specified in [") + kSECTION_VALIDATORS_FILE + "]"); + std::string("Invalid path specified in [") + Sections::kVALIDATORS_FILE + "]"); } if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty()) @@ -987,7 +987,7 @@ Config::loadFromString(std::string const& fileContents) if (!boost::filesystem::exists(validatorsFile)) { Throw( - std::string("The file specified in [") + kSECTION_VALIDATORS_FILE + + std::string("The file specified in [") + Sections::kVALIDATORS_FILE + "] " "does not exist: " + validatorsFile.string()); @@ -997,7 +997,7 @@ Config::loadFromString(std::string const& fileContents) !boost::filesystem::is_symlink(validatorsFile)) { Throw( - std::string("Invalid file specified in [") + kSECTION_VALIDATORS_FILE + + std::string("Invalid file specified in [") + Sections::kVALIDATORS_FILE + "]: " + validatorsFile.string()); } } @@ -1035,44 +1035,44 @@ Config::loadFromString(std::string const& fileContents) auto iniFile = parseIniFile(data, true); - auto entries = getIniFileSection(iniFile, kSECTION_VALIDATORS); + auto entries = getIniFileSection(iniFile, Sections::kVALIDATORS); if (entries != nullptr) - section(kSECTION_VALIDATORS).append(*entries); + section(Sections::kVALIDATORS).append(*entries); - auto valKeyEntries = getIniFileSection(iniFile, kSECTION_VALIDATOR_KEYS); + auto valKeyEntries = getIniFileSection(iniFile, Sections::kVALIDATOR_KEYS); if (valKeyEntries != nullptr) - section(kSECTION_VALIDATOR_KEYS).append(*valKeyEntries); + section(Sections::kVALIDATOR_KEYS).append(*valKeyEntries); - auto valSiteEntries = getIniFileSection(iniFile, kSECTION_VALIDATOR_LIST_SITES); + auto valSiteEntries = getIniFileSection(iniFile, Sections::kVALIDATOR_LIST_SITES); if (valSiteEntries != nullptr) - section(kSECTION_VALIDATOR_LIST_SITES).append(*valSiteEntries); + section(Sections::kVALIDATOR_LIST_SITES).append(*valSiteEntries); - auto valListKeys = getIniFileSection(iniFile, kSECTION_VALIDATOR_LIST_KEYS); + auto valListKeys = getIniFileSection(iniFile, Sections::kVALIDATOR_LIST_KEYS); if (valListKeys != nullptr) - section(kSECTION_VALIDATOR_LIST_KEYS).append(*valListKeys); + section(Sections::kVALIDATOR_LIST_KEYS).append(*valListKeys); - auto valListThreshold = getIniFileSection(iniFile, kSECTION_VALIDATOR_LIST_THRESHOLD); + auto valListThreshold = getIniFileSection(iniFile, Sections::kVALIDATOR_LIST_THRESHOLD); if (valListThreshold != nullptr) - section(kSECTION_VALIDATOR_LIST_THRESHOLD).append(*valListThreshold); + section(Sections::kVALIDATOR_LIST_THRESHOLD).append(*valListThreshold); if ((entries == nullptr) && (valKeyEntries == nullptr) && (valListKeys == nullptr)) { Throw( - std::string("The file specified in [") + kSECTION_VALIDATORS_FILE + + std::string("The file specified in [") + Sections::kVALIDATORS_FILE + "] " "does not contain a [" + - kSECTION_VALIDATORS + + Sections::kVALIDATORS + "], " "[" + - kSECTION_VALIDATOR_KEYS + + Sections::kVALIDATOR_KEYS + "] or " "[" + - kSECTION_VALIDATOR_LIST_KEYS + + Sections::kVALIDATOR_LIST_KEYS + "]" " section: " + validatorsFile.string()); @@ -1080,7 +1080,7 @@ Config::loadFromString(std::string const& fileContents) } VALIDATOR_LIST_THRESHOLD = [&]() -> std::optional { - auto const& listThreshold = section(kSECTION_VALIDATOR_LIST_THRESHOLD); + auto const& listThreshold = section(Sections::kVALIDATOR_LIST_THRESHOLD); if (listThreshold.lines().empty()) { return std::nullopt; @@ -1093,13 +1093,13 @@ Config::loadFromString(std::string const& fileContents) { return std::nullopt; // NOTE: Explicitly ask for computed } - if (listThreshold > section(kSECTION_VALIDATOR_LIST_KEYS).values().size()) + if (listThreshold > section(Sections::kVALIDATOR_LIST_KEYS).values().size()) { Throw( std::string( "Value in config section " "[") + - kSECTION_VALIDATOR_LIST_THRESHOLD + + Sections::kVALIDATOR_LIST_THRESHOLD + "] exceeds the number of configured list keys"); } return listThreshold; @@ -1109,22 +1109,22 @@ Config::loadFromString(std::string const& fileContents) std::string( "Config section " "[") + - kSECTION_VALIDATOR_LIST_THRESHOLD + "] should contain single value only"); + Sections::kVALIDATOR_LIST_THRESHOLD + "] should contain single value only"); }(); // Consolidate [validator_keys] and [validators] - section(kSECTION_VALIDATORS).append(section(kSECTION_VALIDATOR_KEYS).lines()); + section(Sections::kVALIDATORS).append(section(Sections::kVALIDATOR_KEYS).lines()); - if (!section(kSECTION_VALIDATOR_LIST_SITES).lines().empty() && - section(kSECTION_VALIDATOR_LIST_KEYS).lines().empty()) + if (!section(Sections::kVALIDATOR_LIST_SITES).lines().empty() && + section(Sections::kVALIDATOR_LIST_KEYS).lines().empty()) { Throw( - "[" + std::string(kSECTION_VALIDATOR_LIST_KEYS) + "] config section is missing"); + "[" + std::string(Sections::kVALIDATOR_LIST_KEYS) + "] config section is missing"); } } { - auto const part = section(kSECTION_FEATURES); + auto const part = section(Sections::kFEATURES); for (auto const& s : part.values()) { if (auto const f = getRegisteredFeature(s)) @@ -1206,15 +1206,15 @@ setupFeeVote(Section const& section) FeeSetup setup; { std::uint64_t temp = 0; - if (set(temp, kKEY_REFERENCE_FEE, section) && + if (set(temp, Keys::kREFERENCE_FEE, section) && temp <= std::numeric_limits::max()) setup.reference_fee = temp; } { std::uint32_t temp = 0; - if (set(temp, kKEY_ACCOUNT_RESERVE, section)) + if (set(temp, Keys::kACCOUNT_RESERVE, section)) setup.account_reserve = temp; - if (set(temp, kKEY_OWNER_RESERVE, section)) + if (set(temp, Keys::kOWNER_RESERVE, section)) setup.owner_reserve = temp; } return setup; @@ -1227,7 +1227,7 @@ setupDatabaseCon(Config const& c, std::optional j) setup.startUp = c.START_UP; setup.standAlone = c.standalone(); - setup.dataDir = c.legacy(kSECTION_DATABASE_PATH); + setup.dataDir = c.legacy(Sections::kDATABASE_PATH); if (!setup.standAlone && setup.dataDir.empty()) { Throw("database_path must be set."); @@ -1235,7 +1235,7 @@ setupDatabaseCon(Config const& c, std::optional j) if (!setup.globalPragma) { - auto const& sqlite = c.section(kSECTION_SQLITE); + auto const& sqlite = c.section(Sections::kSQLITE); auto result = std::make_unique>(); result->reserve(3); @@ -1353,9 +1353,9 @@ setupDatabaseCon(Config const& c, std::optional j) // TX Pragma int64_t pageSize = 4096; int64_t journalSizeLimit = 1582080; - if (c.exists(kSECTION_SQLITE)) + if (c.exists(Sections::kSQLITE)) { - auto& s = c.section(kSECTION_SQLITE); + auto& s = c.section(Sections::kSQLITE); set(journalSizeLimit, "journal_size_limit", s); set(pageSize, "page_size", s); if (pageSize < 512 || pageSize > 65536) diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 3740e0df35..7c9e20a45c 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -1519,7 +1519,7 @@ setupOverlay(BasicConfig const& config) Overlay::Setup setup; { - auto const& section = config.section(kSECTION_OVERLAY); + auto const& section = config.section(Sections::kOVERLAY); setup.context = makeSslContext(""); set(setup.ipLimit, "ip_limit", section); @@ -1538,7 +1538,7 @@ setupOverlay(BasicConfig const& config) } { - auto const& section = config.section(kSECTION_CRAWL); + auto const& section = config.section(Sections::kCRAWL); auto const& values = section.values(); if (values.size() > 1) @@ -1564,33 +1564,33 @@ setupOverlay(BasicConfig const& config) if (crawlEnabled) { - if (get(section, kKEY_OVERLAY, true)) + if (get(section, Keys::kOVERLAY, true)) { setup.crawlOptions |= CrawlOptions::Overlay; } - if (get(section, kKEY_SERVER, true)) + if (get(section, Keys::kSERVER, true)) { setup.crawlOptions |= CrawlOptions::ServerInfo; } - if (get(section, kKEY_COUNTS, false)) + if (get(section, Keys::kCOUNTS, false)) { setup.crawlOptions |= CrawlOptions::ServerCounts; } - if (get(section, kKEY_UNL, true)) + if (get(section, Keys::kUNL, true)) { setup.crawlOptions |= CrawlOptions::Unl; } } } { - auto const& section = config.section(kSECTION_VL); + auto const& section = config.section(Sections::kVL); set(setup.vlEnabled, "enabled", section); } try { - auto id = config.legacy(kSECTION_NETWORK_ID); + auto id = config.legacy(Sections::kNETWORK_ID); if (!id.empty()) { diff --git a/src/xrpld/perflog/detail/PerfLogImp.cpp b/src/xrpld/perflog/detail/PerfLogImp.cpp index 4c9182ed01..c997b417e0 100644 --- a/src/xrpld/perflog/detail/PerfLogImp.cpp +++ b/src/xrpld/perflog/detail/PerfLogImp.cpp @@ -489,7 +489,7 @@ setupPerfLog(Section const& section, boost::filesystem::path const& configDir) } std::uint64_t logInterval = 0; - if (getIfExists(section, kKEY_LOG_INTERVAL, logInterval)) + if (getIfExists(section, Keys::kLOG_INTERVAL, logInterval)) setup.logInterval = std::chrono::seconds(logInterval); return setup; } diff --git a/src/xrpld/rpc/detail/ServerHandler.cpp b/src/xrpld/rpc/detail/ServerHandler.cpp index ff5fbf2bd4..8796283922 100644 --- a/src/xrpld/rpc/detail/ServerHandler.cpp +++ b/src/xrpld/rpc/detail/ServerHandler.cpp @@ -1129,16 +1129,16 @@ parsePorts(Config const& config, std::ostream& log) { std::vector result; - if (!config.exists(kSECTION_SERVER)) + if (!config.exists(Sections::kSERVER)) { log << "Required section [server] is missing"; Throw(); } ParsedPort common; - parsePort(common, config[kSECTION_SERVER], log); + parsePort(common, config[Sections::kSERVER], log); - auto const& names = config.section(kSECTION_SERVER).values(); + auto const& names = config.section(Sections::kSERVER).values(); result.reserve(names.size()); for (auto const& name : names) { @@ -1150,7 +1150,7 @@ parsePorts(Config const& config, std::ostream& log) // grpc ports are parsed by GRPCServer class. Do not validate // grpc port information in this file. - if (name == kSECTION_PORT_GRPC) + if (name == Sections::kPORT_GRPC) continue; ParsedPort parsed = common;