MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ReadConfigFiles

Method ReadConfigFiles

src/util.cpp:887–960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885}
886
887bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
888{
889 {
890 LOCK(cs_args);
891 m_config_args.clear();
892 }
893
894 const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME);
895 fs::ifstream stream(GetConfigFile(confPath));
896
897 // ok to not have a config file
898 if (stream.good()) {
899 if (!ReadConfigStream(stream, error, ignore_invalid_keys)) {
900 return false;
901 }
902 // if there is an -includeconf in the override args, but it is empty, that means the user
903 // passed '-noincludeconf' on the command line, in which case we should not include anything
904 if (m_override_args.count("-includeconf") == 0) {
905 std::string chain_id = GetChainName();
906 std::vector<std::string> includeconf(GetArgs("-includeconf"));
907 {
908 // We haven't set m_network yet (that happens in SelectParams()), so manually check
909 // for network.includeconf args.
910 std::vector<std::string> includeconf_net(GetArgs(std::string("-") + chain_id + ".includeconf"));
911 includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
912 }
913
914 // Remove -includeconf from configuration, so we can warn about recursion
915 // later
916 {
917 LOCK(cs_args);
918 m_config_args.erase("-includeconf");
919 m_config_args.erase(std::string("-") + chain_id + ".includeconf");
920 }
921
922 for (const std::string& to_include : includeconf) {
923 fs::ifstream include_config(GetConfigFile(to_include));
924 if (include_config.good()) {
925 if (!ReadConfigStream(include_config, error, ignore_invalid_keys)) {
926 return false;
927 }
928 LogPrintf("Included configuration file %s\n", to_include.c_str());
929 } else {
930 error = "Failed to include configuration file " + to_include;
931 return false;
932 }
933 }
934
935 // Warn about recursive -includeconf
936 includeconf = GetArgs("-includeconf");
937 {
938 std::vector<std::string> includeconf_net(GetArgs(std::string("-") + chain_id + ".includeconf"));
939 includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());
940 std::string chain_id_final = GetChainName();
941 if (chain_id_final != chain_id) {
942 // Also warn about recursive includeconf for the chain that was specified in one of the includeconfs
943 includeconf_net = GetArgs(std::string("-") + chain_id_final + ".includeconf");
944 includeconf.insert(includeconf.end(), includeconf_net.begin(), includeconf_net.end());

Callers 3

AppInitRPCFunction · 0.80
AppInitFunction · 0.80
readConfigFilesMethod · 0.80

Calls 9

GetConfigFileFunction · 0.85
ClearDatadirCacheFunction · 0.85
clearMethod · 0.45
countMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
GetArgMethod · 0.45

Tested by

no test coverage detected