|
@@ -6,8 +6,6 @@
|
|
|
#include "boost/property_tree/ptree.hpp"
|
|
|
#include "boost/property_tree/json_parser.hpp"
|
|
|
|
|
|
-Config g_config;
|
|
|
-
|
|
|
// Split a hostport string like "127.0.0.1:12000" at the rightmost colon
|
|
|
// into a host part "127.0.0.1" and a port part "12000".
|
|
|
static bool split_host_port(std::string &host, std::string &port,
|
|
@@ -23,7 +21,8 @@ static bool split_host_port(std::string &host, std::string &port,
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool config_parse(const std::string configstr, const std::string &myname)
|
|
|
+bool config_parse(Config &config, const std::string configstr,
|
|
|
+ const std::string &myname)
|
|
|
{
|
|
|
bool found_my_node = false;
|
|
|
bool found_params = false;
|
|
@@ -38,7 +37,7 @@ bool config_parse(const std::string configstr, const std::string &myname)
|
|
|
if (!entry.first.compare("params")) {
|
|
|
for (auto & pentry : entry.second) {
|
|
|
if (!pentry.first.compare("msgsize")) {
|
|
|
- g_config.msgsize = pentry.second.get_value<uint16_t>();
|
|
|
+ config.msgsize = pentry.second.get_value<uint16_t>();
|
|
|
} else {
|
|
|
std::cerr << "Unknown field in params: " <<
|
|
|
pentry.first << "\n";
|
|
@@ -54,7 +53,7 @@ bool config_parse(const std::string configstr, const std::string &myname)
|
|
|
if (!nentry.first.compare("name")) {
|
|
|
nc.name = nentry.second.get_value<std::string>();
|
|
|
if (!myname.compare(nc.name)) {
|
|
|
- g_config.mynodenum = g_config.nodes.size();
|
|
|
+ config.mynodenum = config.nodes.size();
|
|
|
found_my_node = true;
|
|
|
}
|
|
|
} else if (!nentry.first.compare("pubkey")) {
|
|
@@ -73,7 +72,7 @@ bool config_parse(const std::string configstr, const std::string &myname)
|
|
|
ret = false;
|
|
|
}
|
|
|
}
|
|
|
- g_config.nodes.push_back(std::move(nc));
|
|
|
+ config.nodes.push_back(std::move(nc));
|
|
|
}
|
|
|
} else {
|
|
|
std::cerr << "Unknown key in config: " <<
|