-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig_pool.cpp
More file actions
48 lines (37 loc) · 1.28 KB
/
Copy pathconfig_pool.cpp
File metadata and controls
48 lines (37 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "config_pool.hpp"
#include <btclibs/util/strencodings.h>
#include <yaml-cpp/yaml.h>
namespace dgb
{
std::ofstream& PoolConfig::get_default(std::ofstream& file)
{
YAML::Node out;
// Use the canonical LTC p2pool mainnet prefix when no prefix is set yet
out["prefix"] = m_prefix.empty() ? DEFAULT_PREFIX_HEX : HexStr(m_prefix);
out["worker"] = m_worker;
YAML::Node addrs_node;
for (const auto& host : DEFAULT_BOOTSTRAP_HOSTS)
addrs_node.push_back(host + ":" + std::to_string(P2P_PORT));
out["bootstrap_addrs"] = addrs_node;
file << out;
return file;
}
void PoolConfig::load()
{
YAML::Node node = YAML::LoadFile(m_filepath.string());
// prefix
m_prefix = ParseHexBytes(node["prefix"].as<std::string>());
PARSE_CONFIG(node, worker, std::string);
// Bootstrap addresses: load from YAML if present, otherwise use hardcoded defaults
if (node["bootstrap_addrs"] && node["bootstrap_addrs"].IsSequence())
{
for (const auto& item : node["bootstrap_addrs"])
m_bootstrap_addrs.emplace_back(item.as<std::string>());
}
else
{
for (const auto& host : DEFAULT_BOOTSTRAP_HOSTS)
m_bootstrap_addrs.emplace_back(host + ":" + std::to_string(P2P_PORT));
}
}
} // namespace dgb