6 #ifndef KAGOME_APP_CONFIGURATION_IMPL_HPP 7 #define KAGOME_APP_CONFIGURATION_IMPL_HPP 11 #define RAPIDJSON_NO_SIZETYPEDEFINE 15 #include <rapidjson/document.h> 16 #undef RAPIDJSON_NO_SIZETYPEDEFINE 24 #ifdef DECLARE_PROPERTY 25 #error DECLARE_PROPERTY already defined! 26 #endif // DECLARE_PROPERTY 27 #define DECLARE_PROPERTY(T, N) \ 32 std::conditional<std::is_trivial<T>::value && (sizeof(T) <= sizeof(size_t)), \ 35 N() const override { \ 54 using FilePtr = std::unique_ptr<std::FILE, decltype(&std::fclose)>;
66 [[nodiscard]]
bool initializeFromArgs(
int argc,
const char **argv);
71 boost::filesystem::path chainSpecPath()
const override;
72 boost::filesystem::path runtimeCacheDirPath()
const override;
73 boost::filesystem::path runtimeCachePath(
74 std::string runtime_hash)
const override;
75 boost::filesystem::path chainPath(std::string chain_id)
const override;
76 boost::filesystem::path databasePath(std::string chain_id)
const override;
77 boost::filesystem::path keystorePath(std::string chain_id)
const override;
79 const std::optional<crypto::Ed25519PrivateKey> &
nodeKey()
const override {
83 const std::optional<std::string> &
nodeKeyFile()
const override {
84 return node_key_file_;
88 return save_node_key_;
93 return listen_addresses_;
98 return public_addresses_;
101 const std::vector<libp2p::multi::Multiaddress> &
bootNodes()
const override {
115 return in_peers_light_;
121 return rpc_http_endpoint_;
124 return rpc_ws_endpoint_;
128 return openmetrics_http_endpoint_;
131 return max_ws_connections_;
134 return std::chrono::seconds(random_walk_interval_);
136 const std::vector<std::string> &
log()
const override {
137 return logger_tuning_config_;
140 return max_blocks_in_response_;
143 return peering_config_;
152 return node_version_;
155 return is_telemetry_enabled_;
159 return telemetry_endpoints_;
165 return runtime_exec_method_;
168 return use_wavm_cache_;
171 return purge_wavm_cache_;
174 return offchain_worker_mode_;
177 return enable_offchain_indexing_;
180 return subcommand_chain_info_;
183 return recovery_state_;
186 return storage_backend_;
189 if (dev_mnemonic_phrase_) {
190 return *dev_mnemonic_phrase_;
196 void parse_general_segment(
const rapidjson::Value &val);
197 void parse_blockchain_segment(
const rapidjson::Value &val);
198 void parse_storage_segment(
const rapidjson::Value &val);
199 void parse_network_segment(
const rapidjson::Value &val);
200 void parse_additional_segment(
const rapidjson::Value &val);
205 using Handler = std::function<void(rapidjson::Value &)>;
211 std::vector<SegmentHandler> handlers_ = {
212 SegmentHandler{
"general", std::bind(&AppConfigurationImpl::parse_general_segment,
this, std::placeholders::_1)},
213 SegmentHandler{
"blockchain", std::bind(&AppConfigurationImpl::parse_blockchain_segment,
this, std::placeholders::_1)},
214 SegmentHandler{
"storage", std::bind(&AppConfigurationImpl::parse_storage_segment,
this, std::placeholders::_1)},
215 SegmentHandler{
"network", std::bind(&AppConfigurationImpl::parse_network_segment,
this, std::placeholders::_1)},
216 SegmentHandler{
"additional", std::bind(&AppConfigurationImpl::parse_additional_segment,
this, std::placeholders::_1)},
220 bool validate_config();
222 void read_config_from_file(
const std::string &filepath);
224 bool load_ms(
const rapidjson::Value &val,
226 std::vector<std::string> &target);
228 bool load_ma(
const rapidjson::Value &val,
230 std::vector<libp2p::multi::Multiaddress> &target);
231 bool load_telemetry_uris(
const rapidjson::Value &val,
233 std::vector<telemetry::TelemetryEndpoint> &target);
234 bool load_str(
const rapidjson::Value &val,
236 std::string &target);
237 bool load_u16(
const rapidjson::Value &val,
240 bool load_u32(
const rapidjson::Value &val,
243 bool load_i32(
const rapidjson::Value &val,
246 bool load_bool(
const rapidjson::Value &val,
char const *name,
bool &target);
254 boost::asio::ip::tcp::endpoint getEndpointFrom(
const std::string &host,
255 uint16_t port)
const;
264 outcome::result<boost::asio::ip::tcp::endpoint> getEndpointFrom(
265 const libp2p::multi::Multiaddress &multiaddress)
const;
272 bool testListenAddresses()
const;
281 std::optional<telemetry::TelemetryEndpoint> parseTelemetryEndpoint(
282 const std::string &record)
const;
284 FilePtr open_file(
const std::string &filepath);
336 #undef DECLARE_PROPERTY 338 #endif // KAGOME_APP_CONFIGURATION_IMPL_HPP RuntimeExecutionMethod runtimeExecMethod() const override
const boost::asio::ip::tcp::endpoint & rpcWsEndpoint() const override
boost::asio::ip::tcp::endpoint rpc_ws_endpoint_
bool useWavmCache() const override
network::PeeringConfig peering_config_
boost::asio::ip::tcp::endpoint rpc_http_endpoint_
std::optional< primitives::BlockId > recovery_state_
bool subcommand_chain_info_
std::string openmetrics_http_host_
boost::asio::ip::tcp::endpoint openmetrics_http_endpoint_
uint32_t max_ws_connections_
SyncMethod syncMethod() const override
const std::vector< std::string > & log() const override
std::optional< std::string_view > devMnemonicPhrase() const override
const std::vector< telemetry::TelemetryEndpoint > & telemetryEndpoints() const override
const std::vector< libp2p::multi::Multiaddress > & bootNodes() const override
uint32_t inPeersLight() const override
std::vector< libp2p::multi::Multiaddress > boot_nodes_
std::string node_version_
OffchainWorkerMode offchainWorkerMode() const override
bool enable_offchain_indexing_
bool purgeWavmCache() const override
std::optional< crypto::Ed25519PrivateKey > node_key_
bool subcommandChainInfo() const override
std::vector< std::string > logger_tuning_config_
bool isOffchainIndexingEnabled() const override
std::chrono::seconds getRandomWalkInterval() const override
uint16_t p2pPort() const override
bool isTelemetryEnabled() const override
const std::optional< crypto::Ed25519PrivateKey > & nodeKey() const override
std::optional< boost::filesystem::path > keystore_path_
boost::filesystem::path chain_spec_path_
std::string rpc_http_host_
bool is_telemetry_enabled_
std::vector< libp2p::multi::Multiaddress > listen_addresses_
boost::filesystem::path base_path_
char const * segment_name
std::optional< std::string > dev_mnemonic_phrase_
std::shared_ptr< soralog::Logger > Logger
const std::string & nodeName() const override
std::vector< libp2p::multi::Multiaddress > public_addresses_
uint32_t maxWsConnections() const override
uint32_t max_blocks_in_response_
int32_t luckyPeers() const override
const network::PeeringConfig & peeringConfig() const override
std::optional< primitives::BlockId > recoverState() const override
const std::string & nodeVersion() const override
std::unique_ptr< std::FILE, decltype(&std::fclose)> FilePtr
const boost::asio::ip::tcp::endpoint & openmetricsHttpEndpoint() const override
uint32_t random_walk_interval_
network::Roles roles() const override
std::optional< std::string > node_key_file_
const std::vector< libp2p::multi::Multiaddress > & publicAddresses() const override
const std::vector< libp2p::multi::Multiaddress > & listenAddresses() const override
uint32_t inPeers() const override
const std::optional< std::string > & nodeKeyFile() const override
uint32_t outPeers() const override
const boost::asio::ip::tcp::endpoint & rpcHttpEndpoint() const override
uint32_t maxBlocksInResponse() const override
std::function< void(rapidjson::Value &)> Handler
RuntimeExecutionMethod runtime_exec_method_
uint16_t openmetrics_http_port_
bool shouldSaveNodeKey() const override
StorageBackend storageBackend() const override
bool isRunInDevMode() const override
std::vector< telemetry::TelemetryEndpoint > telemetry_endpoints_
OffchainWorkerMode offchain_worker_mode_