Merge branch 'pulls/266'
This commit is contained in:
commit
f6ca36b6c9
4 changed files with 55 additions and 33 deletions
|
@ -1132,11 +1132,19 @@ node (node_a)
|
|||
|
||||
void rai::bootstrap_listener::start ()
|
||||
{
|
||||
acceptor.open (local.protocol ());
|
||||
acceptor.set_option (boost::asio::ip::tcp::acceptor::reuse_address (true));
|
||||
acceptor.bind (local);
|
||||
acceptor.listen ();
|
||||
accept_connection ();
|
||||
acceptor.open (local.protocol ());
|
||||
acceptor.set_option (boost::asio::ip::tcp::acceptor::reuse_address (true));
|
||||
|
||||
boost::system::error_code ec;
|
||||
acceptor.bind (local, ec);
|
||||
if (ec)
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Error while binding for bootstrap on port %1%: %2%") % local.port() % ec.message ());
|
||||
throw std::runtime_error (ec.message());
|
||||
}
|
||||
|
||||
acceptor.listen ();
|
||||
accept_connection ();
|
||||
}
|
||||
|
||||
void rai::bootstrap_listener::stop ()
|
||||
|
|
|
@ -1500,31 +1500,30 @@ block_processor_thread ([this] () { this->block_processor.process_blocks (); })
|
|||
}
|
||||
}
|
||||
});
|
||||
BOOST_LOG (log) << "Node starting, version: " << RAIBLOCKS_VERSION_MAJOR << "." << RAIBLOCKS_VERSION_MINOR;
|
||||
BOOST_LOG (log) << "Node starting, version: " << RAIBLOCKS_VERSION_MAJOR << "." << RAIBLOCKS_VERSION_MINOR;
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Work pool running %1% threads") % work.threads.size ());
|
||||
if (!init_a.error ())
|
||||
{
|
||||
if (config.logging.node_lifetime_tracing ())
|
||||
{
|
||||
std::cerr << "Constructing node\n";
|
||||
}
|
||||
if (!init_a.error ())
|
||||
{
|
||||
if (config.logging.node_lifetime_tracing ())
|
||||
{
|
||||
BOOST_LOG (log) << "Constructing node";
|
||||
}
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
if (store.latest_begin (transaction) == store.latest_end ())
|
||||
{
|
||||
// Store was empty meaning we just created it, add the genesis block
|
||||
rai::genesis genesis;
|
||||
genesis.initialize (transaction, store);
|
||||
}
|
||||
}
|
||||
if (store.latest_begin (transaction) == store.latest_end ())
|
||||
{
|
||||
// Store was empty meaning we just created it, add the genesis block
|
||||
rai::genesis genesis;
|
||||
genesis.initialize (transaction, store);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rai::node::~node ()
|
||||
{
|
||||
if (config.logging.node_lifetime_tracing ())
|
||||
{
|
||||
std::cerr << "Destructing node\n";
|
||||
BOOST_LOG (log) << "Destructing node";
|
||||
}
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,16 @@ node (node_a)
|
|||
{
|
||||
auto endpoint (rai::tcp_endpoint (config_a.address, config_a.port));
|
||||
acceptor.open (endpoint.protocol ());
|
||||
acceptor.set_option (boost::asio::ip::tcp::acceptor::reuse_address (true));
|
||||
acceptor.bind (endpoint);
|
||||
acceptor.set_option (boost::asio::ip::tcp::acceptor::reuse_address (true));
|
||||
|
||||
boost::system::error_code ec;
|
||||
acceptor.bind (endpoint, ec);
|
||||
if (ec)
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Error while binding for RPC on port %1%: %2%") % endpoint.port() % ec.message ());
|
||||
throw std::runtime_error (ec.message());
|
||||
}
|
||||
|
||||
acceptor.listen ();
|
||||
node_a.observers.blocks.add ([this] (std::shared_ptr <rai::block> block_a, rai::account const & account_a, rai::amount const &)
|
||||
{
|
||||
|
|
|
@ -114,21 +114,28 @@ void rai_daemon::daemon::run (boost::filesystem::path const & data_path)
|
|||
} : std::function <boost::optional <uint64_t> (rai::uint256_union const &)> (nullptr));
|
||||
rai::alarm alarm (service);
|
||||
rai::node_init init;
|
||||
auto node (std::make_shared <rai::node> (init, service, data_path, alarm, config.node, opencl_work));
|
||||
if (!init.error ())
|
||||
try
|
||||
{
|
||||
node->start ();
|
||||
rai::rpc rpc (service, *node, config.rpc);
|
||||
if (config.rpc_enable)
|
||||
auto node (std::make_shared <rai::node> (init, service, data_path, alarm, config.node, opencl_work));
|
||||
if (!init.error ())
|
||||
{
|
||||
rpc.start ();
|
||||
node->start ();
|
||||
rai::rpc rpc (service, *node, config.rpc);
|
||||
if (config.rpc_enable)
|
||||
{
|
||||
rpc.start ();
|
||||
}
|
||||
runner.reset (new rai::thread_runner (service, node->config.io_threads));
|
||||
runner->join ();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error initializing node\n";
|
||||
}
|
||||
runner.reset (new rai::thread_runner (service, node->config.io_threads));
|
||||
runner->join ();
|
||||
}
|
||||
else
|
||||
catch(const std::runtime_error& e)
|
||||
{
|
||||
std::cerr << "Error initializing node\n";
|
||||
std::cerr << "Error while running node (" << e.what() << ")\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue