Adding representative to config.
This commit is contained in:
parent
05f0bf7f37
commit
83920b64e9
3 changed files with 16 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <thread>
|
||||
|
||||
rai_daemon::daemon_config::daemon_config () :
|
||||
representative (rai::genesis_account),
|
||||
peering_port (24000),
|
||||
rpc_enable (false),
|
||||
rpc_address (boost::asio::ip::address_v6::loopback ()),
|
||||
|
@ -18,6 +19,9 @@ rpc_enable_control (false)
|
|||
void rai_daemon::daemon_config::serialize (std::ostream & output_a)
|
||||
{
|
||||
boost::property_tree::ptree tree;
|
||||
std::string representative_l;
|
||||
representative.encode_base58check (representative_l);
|
||||
tree.put ("representative", representative_l);
|
||||
tree.put ("peering_port", std::to_string (peering_port));
|
||||
boost::property_tree::ptree bootstrap_peers_l;
|
||||
for (auto i (bootstrap_peers.begin ()), n (bootstrap_peers.end ()); i != n; ++i)
|
||||
|
@ -41,6 +45,7 @@ rai_daemon::daemon_config::daemon_config (bool & error_a, std::istream & input_a
|
|||
try
|
||||
{
|
||||
boost::property_tree::read_json (input_a, tree);
|
||||
auto representative_l (tree.get <std::string> ("representative"));
|
||||
auto peering_port_l (tree.get <std::string> ("peering_port"));
|
||||
auto rpc_address_l (tree.get <std::string> ("rpc_address"));
|
||||
auto rpc_port_l (tree.get <std::string> ("rpc_port"));
|
||||
|
@ -68,6 +73,7 @@ rai_daemon::daemon_config::daemon_config (bool & error_a, std::istream & input_a
|
|||
{
|
||||
error_a = true;
|
||||
}
|
||||
error_a = error_a | representative.decode_base58check (representative_l);
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
|
@ -106,7 +112,7 @@ void rai_daemon::daemon::run ()
|
|||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::processor_service processor;
|
||||
rai::client_init init;
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, working / "data", processor, rai::genesis_account));
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, working / "data", processor, config.representative));
|
||||
if (!init.error ())
|
||||
{
|
||||
client->processor.connect_bootstrap (config.bootstrap_peers);
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace rai_daemon
|
|||
daemon_config ();
|
||||
daemon_config (bool &, std::istream &);
|
||||
void serialize (std::ostream &);
|
||||
rai::uint256_union representative;
|
||||
std::vector <std::string> bootstrap_peers;
|
||||
uint16_t peering_port;
|
||||
bool rpc_enable;
|
||||
|
|
|
@ -9,6 +9,7 @@ class qt_client_config
|
|||
{
|
||||
public:
|
||||
qt_client_config () :
|
||||
representative (rai::genesis_account),
|
||||
peering_port (24000)
|
||||
{
|
||||
bootstrap_peers.push_back ("rai.raiblocks.net");
|
||||
|
@ -20,6 +21,7 @@ public:
|
|||
try
|
||||
{
|
||||
boost::property_tree::read_json (stream_a, tree);
|
||||
auto representative_l (tree.get <std::string> ("representative"));
|
||||
auto peering_port_l (tree.get <std::string> ("peering_port"));
|
||||
auto bootstrap_peers_l (tree.get_child ("bootstrap_peers"));
|
||||
bootstrap_peers.clear ();
|
||||
|
@ -37,6 +39,7 @@ public:
|
|||
{
|
||||
error_a = true;
|
||||
}
|
||||
error_a = error_a | representative.decode_base58check (representative_l);
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
|
@ -47,6 +50,9 @@ public:
|
|||
void serialize (std::ostream & stream_a)
|
||||
{
|
||||
boost::property_tree::ptree tree;
|
||||
std::string representative_l;
|
||||
representative.encode_base58check (representative_l);
|
||||
tree.put ("representative", representative_l);
|
||||
tree.put ("peering_port", std::to_string (peering_port));
|
||||
boost::property_tree::ptree bootstrap_peers_l;
|
||||
for (auto i (bootstrap_peers.begin ()), n (bootstrap_peers.end ()); i != n; ++i)
|
||||
|
@ -58,6 +64,7 @@ public:
|
|||
tree.add_child ("bootstrap_peers", bootstrap_peers_l);
|
||||
boost::property_tree::write_json (stream_a, tree);
|
||||
}
|
||||
rai::uint256_union representative;
|
||||
std::vector <std::string> bootstrap_peers;
|
||||
uint16_t peering_port;
|
||||
};
|
||||
|
@ -89,7 +96,7 @@ int main (int argc, char ** argv)
|
|||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::processor_service processor;
|
||||
rai::client_init init;
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, boost::filesystem::system_complete (argv[0]).parent_path () / "data", processor, rai::genesis_account));
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, boost::filesystem::system_complete (argv[0]).parent_path () / "data", processor, config.representative));
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&] ()
|
||||
{
|
||||
client->stop ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue