Move from deprecated io_service to io_context (#1469)
This commit is contained in:
parent
331433245a
commit
c230110fba
19 changed files with 389 additions and 389 deletions
|
@ -568,7 +568,7 @@ TEST (ledger, DISABLED_checksum_range)
|
|||
TEST (system, DISABLED_generate_send_existing)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair stake_preserver;
|
||||
auto send_block (system.wallet (0)->send_action (rai::genesis_account, stake_preserver.pub, rai::genesis_amount / 3 * 2, true));
|
||||
|
@ -614,7 +614,7 @@ TEST (system, DISABLED_generate_send_existing)
|
|||
TEST (system, generate_send_new)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
{
|
||||
auto transaction (system.nodes[0]->store.tx_begin ());
|
||||
|
|
|
@ -7,14 +7,14 @@ using namespace std::chrono_literals;
|
|||
|
||||
TEST (network, tcp_connection)
|
||||
{
|
||||
boost::asio::io_service service;
|
||||
boost::asio::ip::tcp::acceptor acceptor (service);
|
||||
boost::asio::io_context io_ctx;
|
||||
boost::asio::ip::tcp::acceptor acceptor (io_ctx);
|
||||
boost::asio::ip::tcp::endpoint endpoint (boost::asio::ip::address_v4::any (), 24000);
|
||||
acceptor.open (endpoint.protocol ());
|
||||
acceptor.set_option (boost::asio::ip::tcp::acceptor::reuse_address (true));
|
||||
acceptor.bind (endpoint);
|
||||
acceptor.listen ();
|
||||
boost::asio::ip::tcp::socket incoming (service);
|
||||
boost::asio::ip::tcp::socket incoming (io_ctx);
|
||||
auto done1 (false);
|
||||
std::string message1;
|
||||
acceptor.async_accept (incoming,
|
||||
|
@ -25,7 +25,7 @@ TEST (network, tcp_connection)
|
|||
std::cerr << message1;
|
||||
}
|
||||
done1 = true; });
|
||||
boost::asio::ip::tcp::socket connector (service);
|
||||
boost::asio::ip::tcp::socket connector (io_ctx);
|
||||
auto done2 (false);
|
||||
std::string message2;
|
||||
connector.async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v4::loopback (), 24000),
|
||||
|
@ -39,7 +39,7 @@ TEST (network, tcp_connection)
|
|||
});
|
||||
while (!done1 || !done2)
|
||||
{
|
||||
service.poll ();
|
||||
io_ctx.poll ();
|
||||
}
|
||||
ASSERT_EQ (0, message1.size ());
|
||||
ASSERT_EQ (0, message2.size ());
|
||||
|
@ -68,7 +68,7 @@ TEST (network, send_node_id_handshake)
|
|||
auto list1 (system.nodes[0]->peers.list ());
|
||||
ASSERT_EQ (0, list1.size ());
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
auto initial (system.nodes[0]->stats.count (rai::stat::type::message, rai::stat::detail::node_id_handshake, rai::stat::dir::in));
|
||||
|
@ -103,7 +103,7 @@ TEST (network, keepalive_ipv4)
|
|||
auto list1 (system.nodes[0]->peers.list ());
|
||||
ASSERT_EQ (0, list1.size ());
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
node1->send_keepalive (rai::endpoint (boost::asio::ip::address_v4::loopback (), 24000));
|
||||
|
@ -122,7 +122,7 @@ TEST (network, multi_keepalive)
|
|||
auto list1 (system.nodes[0]->peers.list ());
|
||||
ASSERT_EQ (0, list1.size ());
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
|
@ -136,7 +136,7 @@ TEST (network, multi_keepalive)
|
|||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
rai::node_init init2;
|
||||
auto node2 (std::make_shared<rai::node> (init2, system.service, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node2 (std::make_shared<rai::node> (init2, system.io_ctx, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init2.error ());
|
||||
node2->start ();
|
||||
system.nodes.push_back (node2);
|
||||
|
@ -550,13 +550,13 @@ TEST (bootstrap_processor, DISABLED_process_none)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
auto done (false);
|
||||
node1->bootstrap_initiator.bootstrap (system.nodes[0]->network.endpoint ());
|
||||
while (!done)
|
||||
{
|
||||
system.service.run_one ();
|
||||
system.io_ctx.run_one ();
|
||||
}
|
||||
node1->stop ();
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ TEST (bootstrap_processor, process_one)
|
|||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, rai::test_genesis_key.pub, 100));
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
rai::block_hash hash1 (system.nodes[0]->latest (rai::test_genesis_key.pub));
|
||||
rai::block_hash hash2 (node1->latest (rai::test_genesis_key.pub));
|
||||
ASSERT_NE (hash1, hash2);
|
||||
|
@ -596,7 +596,7 @@ TEST (bootstrap_processor, process_two)
|
|||
ASSERT_NE (hash1, hash3);
|
||||
ASSERT_NE (hash2, hash3);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->bootstrap_initiator.bootstrap (system.nodes[0]->network.endpoint ());
|
||||
ASSERT_NE (node1->latest (rai::test_genesis_key.pub), system.nodes[0]->latest (rai::test_genesis_key.pub));
|
||||
|
@ -622,7 +622,7 @@ TEST (bootstrap_processor, process_state)
|
|||
node0->process (*block1);
|
||||
node0->process (*block2);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_EQ (node0->latest (rai::test_genesis_key.pub), block2->hash ());
|
||||
ASSERT_NE (node1->latest (rai::test_genesis_key.pub), block2->hash ());
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
|
@ -651,7 +651,7 @@ TEST (bootstrap_processor, process_new)
|
|||
rai::uint128_t balance1 (system.nodes[0]->balance (rai::test_genesis_key.pub));
|
||||
rai::uint128_t balance2 (system.nodes[0]->balance (key2.pub));
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->bootstrap_initiator.bootstrap (system.nodes[0]->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
|
@ -676,7 +676,7 @@ TEST (bootstrap_processor, pull_diamond)
|
|||
auto receive (std::make_shared<rai::receive_block> (send1->hash (), send2->hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (send1->hash ())));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes[0]->process (*receive).code);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->bootstrap_initiator.bootstrap (system.nodes[0]->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
|
@ -693,7 +693,7 @@ TEST (bootstrap_processor, push_diamond)
|
|||
rai::system system (24000, 1);
|
||||
rai::keypair key;
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24002, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
auto wallet1 (node1->wallets.create (100));
|
||||
wallet1->insert_adhoc (rai::test_genesis_key.prv);
|
||||
|
@ -721,7 +721,7 @@ TEST (bootstrap_processor, push_one)
|
|||
rai::system system (24000, 1);
|
||||
rai::node_init init1;
|
||||
rai::keypair key1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto wallet (node1->wallets.create (rai::uint256_union ()));
|
||||
ASSERT_NE (nullptr, wallet);
|
||||
wallet->insert_adhoc (rai::test_genesis_key.prv);
|
||||
|
@ -756,7 +756,7 @@ TEST (bootstrap_processor, lazy_hash)
|
|||
system.nodes[0]->block_processor.add (receive2, std::chrono::steady_clock::time_point ());
|
||||
system.nodes[0]->block_processor.flush ();
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
node1->peers.insert (system.nodes[0]->network.endpoint (), rai::protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (receive2->hash ());
|
||||
// Check processed blocks
|
||||
|
@ -793,7 +793,7 @@ TEST (bootstrap_processor, lazy_max_pull_count)
|
|||
system.nodes[0]->block_processor.add (change3, std::chrono::steady_clock::time_point ());
|
||||
system.nodes[0]->block_processor.flush ();
|
||||
// Start lazy bootstrap with last block in chain known
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
node1->peers.insert (system.nodes[0]->network.endpoint (), rai::protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (change3->hash ());
|
||||
// Check processed blocks
|
||||
|
@ -808,7 +808,7 @@ TEST (bootstrap_processor, lazy_max_pull_count)
|
|||
TEST (frontier_req_response, DISABLED_destruction)
|
||||
{
|
||||
{
|
||||
std::shared_ptr<rai::frontier_req_server> hold; // Destructing tcp acceptor on non-existent io_service
|
||||
std::shared_ptr<rai::frontier_req_server> hold; // Destructing tcp acceptor on non-existent io_context
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared<rai::bootstrap_server> (nullptr, system.nodes[0]));
|
||||
|
@ -928,7 +928,7 @@ TEST (bulk, genesis)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
rai::block_hash latest1 (system.nodes[0]->latest (rai::test_genesis_key.pub));
|
||||
rai::block_hash latest2 (node1->latest (rai::test_genesis_key.pub));
|
||||
|
@ -952,7 +952,7 @@ TEST (bulk, offline_send)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
|
@ -1022,19 +1022,19 @@ TEST (network, ipv6_from_ipv4)
|
|||
|
||||
TEST (network, ipv6_bind_send_ipv4)
|
||||
{
|
||||
boost::asio::io_service service;
|
||||
boost::asio::io_context io_ctx;
|
||||
rai::endpoint endpoint1 (boost::asio::ip::address_v6::any (), 24000);
|
||||
rai::endpoint endpoint2 (boost::asio::ip::address_v4::any (), 24001);
|
||||
std::array<uint8_t, 16> bytes1;
|
||||
auto finish1 (false);
|
||||
rai::endpoint endpoint3;
|
||||
boost::asio::ip::udp::socket socket1 (service, endpoint1);
|
||||
boost::asio::ip::udp::socket socket1 (io_ctx, endpoint1);
|
||||
socket1.async_receive_from (boost::asio::buffer (bytes1.data (), bytes1.size ()), endpoint3, [&finish1](boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
finish1 = true;
|
||||
});
|
||||
boost::asio::ip::udp::socket socket2 (service, endpoint2);
|
||||
boost::asio::ip::udp::socket socket2 (io_ctx, endpoint2);
|
||||
rai::endpoint endpoint5 (boost::asio::ip::address_v4::loopback (), 24000);
|
||||
rai::endpoint endpoint6 (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4::loopback ()), 24001);
|
||||
socket2.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint5, [](boost::system::error_code const & error, size_t size_a) {
|
||||
|
@ -1044,7 +1044,7 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
auto iterations (0);
|
||||
while (!finish1)
|
||||
{
|
||||
service.poll ();
|
||||
io_ctx.poll ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@ TEST (node, stop)
|
|||
rai::system system (24000, 1);
|
||||
ASSERT_NE (system.nodes[0]->wallets.items.end (), system.nodes[0]->wallets.items.begin ());
|
||||
system.nodes[0]->stop ();
|
||||
system.service.run ();
|
||||
system.io_ctx.run ();
|
||||
ASSERT_TRUE (true);
|
||||
}
|
||||
|
||||
TEST (node, block_store_path_failure)
|
||||
{
|
||||
rai::node_init init;
|
||||
auto service (boost::make_shared<boost::asio::io_service> ());
|
||||
auto service (boost::make_shared<boost::asio::io_context> ());
|
||||
rai::alarm alarm (*service);
|
||||
auto path (rai::unique_path ());
|
||||
rai::logging logging;
|
||||
|
@ -34,7 +34,7 @@ TEST (node, block_store_path_failure)
|
|||
TEST (node, password_fanout)
|
||||
{
|
||||
rai::node_init init;
|
||||
auto service (boost::make_shared<boost::asio::io_service> ());
|
||||
auto service (boost::make_shared<boost::asio::io_context> ());
|
||||
rai::alarm alarm (*service);
|
||||
auto path (rai::unique_path ());
|
||||
rai::node_config config;
|
||||
|
@ -222,7 +222,7 @@ TEST (node, auto_bootstrap)
|
|||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->network.send_keepalive (system.nodes[0]->network.endpoint ());
|
||||
node1->start ();
|
||||
|
@ -251,7 +251,7 @@ TEST (node, auto_bootstrap_reverse)
|
|||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
system.nodes[0]->network.send_keepalive (node1->network.endpoint ());
|
||||
|
@ -380,7 +380,7 @@ TEST (node, connect_after_junk)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
uint64_t junk (0);
|
||||
node1->network.socket.async_send_to (boost::asio::buffer (&junk, sizeof (junk)), system.nodes[0]->network.endpoint (), [](boost::system::error_code const &, size_t) {});
|
||||
system.deadline_set (10s);
|
||||
|
|
|
@ -48,8 +48,8 @@ TEST (processor_service, bad_receive_signature)
|
|||
|
||||
TEST (alarm, one)
|
||||
{
|
||||
boost::asio::io_service service;
|
||||
rai::alarm alarm (service);
|
||||
boost::asio::io_context io_ctx;
|
||||
rai::alarm alarm (io_ctx);
|
||||
std::atomic<bool> done (false);
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
|
@ -60,18 +60,18 @@ TEST (alarm, one)
|
|||
}
|
||||
condition.notify_one ();
|
||||
});
|
||||
boost::asio::io_service::work work (service);
|
||||
boost::thread thread ([&service]() { service.run (); });
|
||||
boost::asio::io_context::work work (io_ctx);
|
||||
boost::thread thread ([&io_ctx]() { io_ctx.run (); });
|
||||
std::unique_lock<std::mutex> unique (mutex);
|
||||
condition.wait (unique, [&]() { return !!done; });
|
||||
service.stop ();
|
||||
io_ctx.stop ();
|
||||
thread.join ();
|
||||
}
|
||||
|
||||
TEST (alarm, many)
|
||||
{
|
||||
boost::asio::io_service service;
|
||||
rai::alarm alarm (service);
|
||||
boost::asio::io_context io_ctx;
|
||||
rai::alarm alarm (io_ctx);
|
||||
std::atomic<int> count (0);
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
|
@ -85,15 +85,15 @@ TEST (alarm, many)
|
|||
condition.notify_one ();
|
||||
});
|
||||
}
|
||||
boost::asio::io_service::work work (service);
|
||||
boost::asio::io_context::work work (io_ctx);
|
||||
std::vector<boost::thread> threads;
|
||||
for (auto i (0); i < 50; ++i)
|
||||
{
|
||||
threads.push_back (boost::thread ([&service]() { service.run (); }));
|
||||
threads.push_back (boost::thread ([&io_ctx]() { io_ctx.run (); }));
|
||||
}
|
||||
std::unique_lock<std::mutex> unique (mutex);
|
||||
condition.wait (unique, [&]() { return count == 50; });
|
||||
service.stop ();
|
||||
io_ctx.stop ();
|
||||
for (auto i (threads.begin ()), j (threads.end ()); i != j; ++i)
|
||||
{
|
||||
i->join ();
|
||||
|
@ -102,8 +102,8 @@ TEST (alarm, many)
|
|||
|
||||
TEST (alarm, top_execution)
|
||||
{
|
||||
boost::asio::io_service service;
|
||||
rai::alarm alarm (service);
|
||||
boost::asio::io_context io_ctx;
|
||||
rai::alarm alarm (io_ctx);
|
||||
int value1 (0);
|
||||
int value2 (0);
|
||||
std::mutex mutex;
|
||||
|
@ -118,14 +118,14 @@ TEST (alarm, top_execution)
|
|||
value2 = 2;
|
||||
promise.set_value (false);
|
||||
});
|
||||
boost::asio::io_service::work work (service);
|
||||
boost::thread thread ([&service]() {
|
||||
service.run ();
|
||||
boost::asio::io_context::work work (io_ctx);
|
||||
boost::thread thread ([&io_ctx]() {
|
||||
io_ctx.run ();
|
||||
});
|
||||
promise.get_future ().get ();
|
||||
std::lock_guard<std::mutex> lock (mutex);
|
||||
ASSERT_EQ (1, value1);
|
||||
ASSERT_EQ (2, value2);
|
||||
service.stop ();
|
||||
io_ctx.stop ();
|
||||
thread.join ();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -880,7 +880,7 @@ TEST (wallet, send_race)
|
|||
TEST (wallet, password_race)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
auto wallet = system.wallet (0);
|
||||
system.nodes[0]->background ([&wallet]() {
|
||||
for (int i = 0; i < 100; i++)
|
||||
|
@ -907,7 +907,7 @@ TEST (wallet, password_race)
|
|||
TEST (wallet, password_race_corrupt_seed)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
auto wallet = system.wallet (0);
|
||||
rai::raw_key seed;
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ constexpr unsigned bootstrap_max_new_connections = 10;
|
|||
constexpr unsigned bulk_push_cost_limit = 200;
|
||||
|
||||
rai::socket::socket (std::shared_ptr<rai::node> node_a) :
|
||||
socket_m (node_a->service),
|
||||
socket_m (node_a->io_ctx),
|
||||
cutoff (std::numeric_limits<uint64_t>::max ()),
|
||||
node (node_a)
|
||||
{
|
||||
|
@ -809,7 +809,7 @@ bool rai::bootstrap_attempt::request_frontier (std::unique_lock<std::mutex> & lo
|
|||
future = client->promise.get_future ();
|
||||
}
|
||||
lock_a.unlock ();
|
||||
result = consume_future (future); // This is out of scope of `client' so when the last reference via boost::asio::io_service is lost and the client is destroyed, the future throws an exception.
|
||||
result = consume_future (future); // This is out of scope of `client' so when the last reference via boost::asio::io_context is lost and the client is destroyed, the future throws an exception.
|
||||
lock_a.lock ();
|
||||
if (result)
|
||||
{
|
||||
|
@ -870,7 +870,7 @@ void rai::bootstrap_attempt::request_push (std::unique_lock<std::mutex> & lock_a
|
|||
future = client->promise.get_future ();
|
||||
}
|
||||
lock_a.unlock ();
|
||||
error = consume_future (future); // This is out of scope of `client' so when the last reference via boost::asio::io_service is lost and the client is destroyed, the future throws an exception.
|
||||
error = consume_future (future); // This is out of scope of `client' so when the last reference via boost::asio::io_context is lost and the client is destroyed, the future throws an exception.
|
||||
lock_a.lock ();
|
||||
}
|
||||
if (node->config.logging.network_logging ())
|
||||
|
@ -1618,10 +1618,10 @@ void rai::bootstrap_initiator::notify_listeners (bool in_progress_a)
|
|||
}
|
||||
}
|
||||
|
||||
rai::bootstrap_listener::bootstrap_listener (boost::asio::io_service & service_a, uint16_t port_a, rai::node & node_a) :
|
||||
acceptor (service_a),
|
||||
rai::bootstrap_listener::bootstrap_listener (boost::asio::io_context & io_ctx_a, uint16_t port_a, rai::node & node_a) :
|
||||
acceptor (io_ctx_a),
|
||||
local (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v6::any (), port_a)),
|
||||
service (service_a),
|
||||
io_ctx (io_ctx_a),
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ class bootstrap_server;
|
|||
class bootstrap_listener
|
||||
{
|
||||
public:
|
||||
bootstrap_listener (boost::asio::io_service &, uint16_t, rai::node &);
|
||||
bootstrap_listener (boost::asio::io_context &, uint16_t, rai::node &);
|
||||
void start ();
|
||||
void stop ();
|
||||
void accept_connection ();
|
||||
|
@ -229,7 +229,7 @@ public:
|
|||
rai::tcp_endpoint endpoint ();
|
||||
boost::asio::ip::tcp::acceptor acceptor;
|
||||
rai::tcp_endpoint local;
|
||||
boost::asio::io_service & service;
|
||||
boost::asio::io_context & io_ctx;
|
||||
rai::node & node;
|
||||
bool on;
|
||||
};
|
||||
|
|
|
@ -35,8 +35,8 @@ extern size_t rai_bootstrap_weights_size;
|
|||
|
||||
rai::network::network (rai::node & node_a, uint16_t port) :
|
||||
buffer_container (node_a.stats, rai::network::buffer_size, 4096), // 2Mb receive buffer
|
||||
socket (node_a.service, rai::endpoint (boost::asio::ip::address_v6::any (), port)),
|
||||
resolver (node_a.service),
|
||||
socket (node_a.io_ctx, rai::endpoint (boost::asio::ip::address_v6::any (), port)),
|
||||
resolver (node_a.io_ctx),
|
||||
node (node_a),
|
||||
on (true)
|
||||
{
|
||||
|
@ -704,8 +704,8 @@ bool rai::operation::operator> (rai::operation const & other_a) const
|
|||
return wakeup > other_a.wakeup;
|
||||
}
|
||||
|
||||
rai::alarm::alarm (boost::asio::io_service & service_a) :
|
||||
service (service_a),
|
||||
rai::alarm::alarm (boost::asio::io_context & io_ctx_a) :
|
||||
io_ctx (io_ctx_a),
|
||||
thread ([this]() {
|
||||
rai::thread_role::set (rai::thread_role::name::alarm);
|
||||
run ();
|
||||
|
@ -732,7 +732,7 @@ void rai::alarm::run ()
|
|||
{
|
||||
if (operation.wakeup <= std::chrono::steady_clock::now ())
|
||||
{
|
||||
service.post (operation.function);
|
||||
io_ctx.post (operation.function);
|
||||
operations.pop ();
|
||||
}
|
||||
else
|
||||
|
@ -1592,13 +1592,13 @@ void rai::block_processor::queue_unchecked (rai::transaction const & transaction
|
|||
node.gap_cache.blocks.get<1> ().erase (hash_a);
|
||||
}
|
||||
|
||||
rai::node::node (rai::node_init & init_a, boost::asio::io_service & service_a, uint16_t peering_port_a, boost::filesystem::path const & application_path_a, rai::alarm & alarm_a, rai::logging const & logging_a, rai::work_pool & work_a) :
|
||||
node (init_a, service_a, application_path_a, alarm_a, rai::node_config (peering_port_a, logging_a), work_a)
|
||||
rai::node::node (rai::node_init & init_a, boost::asio::io_context & io_ctx_a, uint16_t peering_port_a, boost::filesystem::path const & application_path_a, rai::alarm & alarm_a, rai::logging const & logging_a, rai::work_pool & work_a) :
|
||||
node (init_a, io_ctx_a, application_path_a, alarm_a, rai::node_config (peering_port_a, logging_a), work_a)
|
||||
{
|
||||
}
|
||||
|
||||
rai::node::node (rai::node_init & init_a, boost::asio::io_service & service_a, boost::filesystem::path const & application_path_a, rai::alarm & alarm_a, rai::node_config const & config_a, rai::work_pool & work_a) :
|
||||
service (service_a),
|
||||
rai::node::node (rai::node_init & init_a, boost::asio::io_context & io_ctx_a, boost::filesystem::path const & application_path_a, rai::alarm & alarm_a, rai::node_config const & config_a, rai::work_pool & work_a) :
|
||||
io_ctx (io_ctx_a),
|
||||
config (config_a),
|
||||
alarm (alarm_a),
|
||||
work (work_a),
|
||||
|
@ -1609,7 +1609,7 @@ ledger (store, stats, config.epoch_block_link, config.epoch_block_signer),
|
|||
active (*this),
|
||||
network (*this, config.peering_port),
|
||||
bootstrap_initiator (*this),
|
||||
bootstrap (service_a, config.peering_port, *this),
|
||||
bootstrap (io_ctx_a, config.peering_port, *this),
|
||||
peers (network.endpoint ()),
|
||||
application_path (application_path_a),
|
||||
wallets (init_a.block_store_init, *this),
|
||||
|
@ -1659,13 +1659,13 @@ vote_uniquer (block_uniquer)
|
|||
auto address (node_l->config.callback_address);
|
||||
auto port (node_l->config.callback_port);
|
||||
auto target (std::make_shared<std::string> (node_l->config.callback_target));
|
||||
auto resolver (std::make_shared<boost::asio::ip::tcp::resolver> (node_l->service));
|
||||
auto resolver (std::make_shared<boost::asio::ip::tcp::resolver> (node_l->io_ctx));
|
||||
resolver->async_resolve (boost::asio::ip::tcp::resolver::query (address, std::to_string (port)), [node_l, address, port, target, body, resolver](boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator i_a) {
|
||||
if (!ec)
|
||||
{
|
||||
for (auto i (i_a), n (boost::asio::ip::tcp::resolver::iterator{}); i != n; ++i)
|
||||
{
|
||||
auto sock (std::make_shared<boost::asio::ip::tcp::socket> (node_l->service));
|
||||
auto sock (std::make_shared<boost::asio::ip::tcp::socket> (node_l->io_ctx));
|
||||
sock->async_connect (i->endpoint (), [node_l, target, body, sock, address, port](boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
|
@ -2262,10 +2262,10 @@ namespace
|
|||
class work_request
|
||||
{
|
||||
public:
|
||||
work_request (boost::asio::io_service & service_a, boost::asio::ip::address address_a, uint16_t port_a) :
|
||||
work_request (boost::asio::io_context & io_ctx_a, boost::asio::ip::address address_a, uint16_t port_a) :
|
||||
address (address_a),
|
||||
port (port_a),
|
||||
socket (service_a)
|
||||
socket (io_ctx_a)
|
||||
{
|
||||
}
|
||||
boost::asio::ip::address address;
|
||||
|
@ -2342,7 +2342,7 @@ public:
|
|||
auto host (i.first);
|
||||
auto service (i.second);
|
||||
node->background ([this_l, host, service]() {
|
||||
auto connection (std::make_shared<work_request> (this_l->node->service, host, service));
|
||||
auto connection (std::make_shared<work_request> (this_l->node->io_ctx, host, service));
|
||||
connection->socket.async_connect (rai::tcp_endpoint (host, service), [this_l, connection](boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
|
@ -2428,7 +2428,7 @@ public:
|
|||
request.version (11);
|
||||
request.body () = request_string;
|
||||
request.prepare_payload ();
|
||||
auto socket (std::make_shared<boost::asio::ip::tcp::socket> (this_l->node->service));
|
||||
auto socket (std::make_shared<boost::asio::ip::tcp::socket> (this_l->node->io_ctx));
|
||||
boost::beast::http::async_write (*socket, request, [socket](boost::system::error_code const & ec, size_t bytes_transferred) {
|
||||
});
|
||||
});
|
||||
|
@ -3579,24 +3579,24 @@ int rai::node::store_version ()
|
|||
return store.version_get (transaction);
|
||||
}
|
||||
|
||||
rai::thread_runner::thread_runner (boost::asio::io_service & service_a, unsigned service_threads_a)
|
||||
rai::thread_runner::thread_runner (boost::asio::io_context & io_ctx_a, unsigned service_threads_a)
|
||||
{
|
||||
boost::thread::attributes attrs;
|
||||
rai::thread_attributes::set (attrs);
|
||||
for (auto i (0); i < service_threads_a; ++i)
|
||||
{
|
||||
threads.push_back (boost::thread (attrs, [&service_a]() {
|
||||
threads.push_back (boost::thread (attrs, [&io_ctx_a]() {
|
||||
rai::thread_role::set (rai::thread_role::name::io);
|
||||
try
|
||||
{
|
||||
service_a.run ();
|
||||
io_ctx_a.run ();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
/*
|
||||
* In a release build, catch and swallow the
|
||||
* service exception, in debug mode pass it
|
||||
* io_context exception, in debug mode pass it
|
||||
* on
|
||||
*/
|
||||
throw;
|
||||
|
@ -3624,8 +3624,8 @@ void rai::thread_runner::join ()
|
|||
|
||||
rai::inactive_node::inactive_node (boost::filesystem::path const & path) :
|
||||
path (path),
|
||||
service (std::make_shared<boost::asio::io_service> ()),
|
||||
alarm (*service),
|
||||
io_context (std::make_shared<boost::asio::io_context> ()),
|
||||
alarm (*io_context),
|
||||
work (1, nullptr)
|
||||
{
|
||||
boost::system::error_code error_chmod;
|
||||
|
@ -3637,7 +3637,7 @@ work (1, nullptr)
|
|||
rai::set_secure_perm_directory (path, error_chmod);
|
||||
logging.max_size = std::numeric_limits<std::uintmax_t>::max ();
|
||||
logging.init (path);
|
||||
node = std::make_shared<rai::node> (init, *service, 24000, path, alarm, logging, work);
|
||||
node = std::make_shared<rai::node> (init, *io_context, 24000, path, alarm, logging, work);
|
||||
}
|
||||
|
||||
rai::inactive_node::~inactive_node ()
|
||||
|
|
|
@ -147,11 +147,11 @@ public:
|
|||
class alarm
|
||||
{
|
||||
public:
|
||||
alarm (boost::asio::io_service &);
|
||||
alarm (boost::asio::io_context &);
|
||||
~alarm ();
|
||||
void add (std::chrono::steady_clock::time_point const &, std::function<void()> const &);
|
||||
void run ();
|
||||
boost::asio::io_service & service;
|
||||
boost::asio::io_context & io_ctx;
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
std::priority_queue<operation, std::vector<operation>, std::greater<operation>> operations;
|
||||
|
@ -446,13 +446,13 @@ private:
|
|||
class node : public std::enable_shared_from_this<rai::node>
|
||||
{
|
||||
public:
|
||||
node (rai::node_init &, boost::asio::io_service &, uint16_t, boost::filesystem::path const &, rai::alarm &, rai::logging const &, rai::work_pool &);
|
||||
node (rai::node_init &, boost::asio::io_service &, boost::filesystem::path const &, rai::alarm &, rai::node_config const &, rai::work_pool &);
|
||||
node (rai::node_init &, boost::asio::io_context &, uint16_t, boost::filesystem::path const &, rai::alarm &, rai::logging const &, rai::work_pool &);
|
||||
node (rai::node_init &, boost::asio::io_context &, boost::filesystem::path const &, rai::alarm &, rai::node_config const &, rai::work_pool &);
|
||||
~node ();
|
||||
template <typename T>
|
||||
void background (T action_a)
|
||||
{
|
||||
alarm.service.post (action_a);
|
||||
alarm.io_ctx.post (action_a);
|
||||
}
|
||||
void send_keepalive (rai::endpoint const &);
|
||||
bool copy_with_compaction (boost::filesystem::path const &);
|
||||
|
@ -489,7 +489,7 @@ public:
|
|||
void process_fork (rai::transaction const &, std::shared_ptr<rai::block>);
|
||||
bool validate_block_by_previous (rai::transaction const &, std::shared_ptr<rai::block>);
|
||||
rai::uint128_t delta ();
|
||||
boost::asio::io_service & service;
|
||||
boost::asio::io_context & io_ctx;
|
||||
rai::node_config config;
|
||||
rai::node_flags flags;
|
||||
rai::alarm & alarm;
|
||||
|
@ -531,7 +531,7 @@ public:
|
|||
class thread_runner
|
||||
{
|
||||
public:
|
||||
thread_runner (boost::asio::io_service &, unsigned);
|
||||
thread_runner (boost::asio::io_context &, unsigned);
|
||||
~thread_runner ();
|
||||
void join ();
|
||||
std::vector<boost::thread> threads;
|
||||
|
@ -542,7 +542,7 @@ public:
|
|||
inactive_node (boost::filesystem::path const & path = rai::working_path ());
|
||||
~inactive_node ();
|
||||
boost::filesystem::path path;
|
||||
std::shared_ptr<boost::asio::io_service> service;
|
||||
std::shared_ptr<boost::asio::io_context> io_context;
|
||||
rai::alarm alarm;
|
||||
rai::logging logging;
|
||||
rai::node_init init;
|
||||
|
|
|
@ -122,8 +122,8 @@ bool rai::rpc_config::deserialize_json (boost::property_tree::ptree const & tree
|
|||
return result;
|
||||
}
|
||||
|
||||
rai::rpc::rpc (boost::asio::io_service & service_a, rai::node & node_a, rai::rpc_config const & config_a) :
|
||||
acceptor (service_a),
|
||||
rai::rpc::rpc (boost::asio::io_context & io_ctx_a, rai::node & node_a, rai::rpc_config const & config_a) :
|
||||
acceptor (io_ctx_a),
|
||||
config (config_a),
|
||||
node (node_a)
|
||||
{
|
||||
|
@ -3713,7 +3713,7 @@ void rai::rpc_handler::work_peers_clear ()
|
|||
rai::rpc_connection::rpc_connection (rai::node & node_a, rai::rpc & rpc_a) :
|
||||
node (node_a.shared ()),
|
||||
rpc (rpc_a),
|
||||
socket (node_a.service)
|
||||
socket (node_a.io_ctx)
|
||||
{
|
||||
responded.clear ();
|
||||
}
|
||||
|
@ -4391,21 +4391,21 @@ void rai::payment_observer::complete (rai::payment_status status)
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<rai::rpc> rai::get_rpc (boost::asio::io_service & service_a, rai::node & node_a, rai::rpc_config const & config_a)
|
||||
std::unique_ptr<rai::rpc> rai::get_rpc (boost::asio::io_context & io_ctx_a, rai::node & node_a, rai::rpc_config const & config_a)
|
||||
{
|
||||
std::unique_ptr<rpc> impl;
|
||||
|
||||
if (config_a.secure.enable)
|
||||
{
|
||||
#ifdef RAIBLOCKS_SECURE_RPC
|
||||
impl.reset (new rpc_secure (service_a, node_a, config_a));
|
||||
impl.reset (new rpc_secure (io_ctx_a, node_a, config_a));
|
||||
#else
|
||||
std::cerr << "RPC configured for TLS, but the node is not compiled with TLS support" << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
impl.reset (new rpc (service_a, node_a, config_a));
|
||||
impl.reset (new rpc (io_ctx_a, node_a, config_a));
|
||||
}
|
||||
|
||||
return impl;
|
||||
|
|
|
@ -65,7 +65,7 @@ class payment_observer;
|
|||
class rpc
|
||||
{
|
||||
public:
|
||||
rpc (boost::asio::io_service &, rai::node &, rai::rpc_config const &);
|
||||
rpc (boost::asio::io_context &, rai::node &, rai::rpc_config const &);
|
||||
virtual ~rpc () = default;
|
||||
void start ();
|
||||
virtual void accept ();
|
||||
|
@ -241,5 +241,5 @@ public:
|
|||
bool rpc_control_impl ();
|
||||
};
|
||||
/** Returns the correct RPC implementation based on TLS configuration */
|
||||
std::unique_ptr<rai::rpc> get_rpc (boost::asio::io_service & service_a, rai::node & node_a, rai::rpc_config const & config_a);
|
||||
std::unique_ptr<rai::rpc> get_rpc (boost::asio::io_context & io_ctx_a, rai::node & node_a, rai::rpc_config const & config_a);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ std::string rai::error_system_messages::message (int ev) const
|
|||
}
|
||||
|
||||
rai::system::system (uint16_t port_a, size_t count_a) :
|
||||
alarm (service),
|
||||
alarm (io_ctx),
|
||||
work (1, nullptr)
|
||||
{
|
||||
auto scale_str = std::getenv ("DEADLINE_SCALE_FACTOR");
|
||||
|
@ -32,7 +32,7 @@ work (1, nullptr)
|
|||
{
|
||||
rai::node_init init;
|
||||
rai::node_config config (port_a + i, logging);
|
||||
auto node (std::make_shared<rai::node> (init, service, rai::unique_path (), alarm, config, work));
|
||||
auto node (std::make_shared<rai::node> (init, io_ctx, rai::unique_path (), alarm, config, work));
|
||||
assert (!init.error ());
|
||||
node->start ();
|
||||
rai::uint256_union wallet;
|
||||
|
@ -105,7 +105,7 @@ void rai::system::deadline_set (std::chrono::duration<double, std::nano> const &
|
|||
std::error_code rai::system::poll (std::chrono::nanoseconds const & wait_time)
|
||||
{
|
||||
std::error_code ec;
|
||||
service.run_one_for (wait_time);
|
||||
io_ctx.run_one_for (wait_time);
|
||||
|
||||
if (std::chrono::steady_clock::now () > deadline)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
std::error_code poll (const std::chrono::nanoseconds & sleep_time = std::chrono::milliseconds (50));
|
||||
void stop ();
|
||||
void deadline_set (const std::chrono::duration<double, std::nano> & delta);
|
||||
boost::asio::io_service service;
|
||||
boost::asio::io_context io_ctx;
|
||||
rai::alarm alarm;
|
||||
std::vector<std::shared_ptr<rai::node>> nodes;
|
||||
rai::logging logging;
|
||||
|
|
|
@ -25,7 +25,7 @@ int main (int argc, char ** argv)
|
|||
client_tabs->addTab (guis.back ()->client_window, boost::str (boost::format ("Wallet %1%") % i).c_str ());
|
||||
}
|
||||
client_tabs->show ();
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&]() {
|
||||
system.stop ();
|
||||
});
|
||||
|
|
|
@ -109,27 +109,27 @@ void rai_daemon::daemon::run (boost::filesystem::path const & data_path, rai::no
|
|||
{
|
||||
config.node.logging.init (data_path);
|
||||
config_file.close ();
|
||||
boost::asio::io_service service;
|
||||
boost::asio::io_context io_ctx;
|
||||
auto opencl (rai::opencl_work::create (config.opencl_enable, config.opencl, config.node.logging));
|
||||
rai::work_pool opencl_work (config.node.work_threads, opencl ? [&opencl](rai::uint256_union const & root_a) {
|
||||
return opencl->generate_work (root_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (rai::uint256_union const &)> (nullptr));
|
||||
rai::alarm alarm (service);
|
||||
rai::alarm alarm (io_ctx);
|
||||
rai::node_init init;
|
||||
try
|
||||
{
|
||||
auto node (std::make_shared<rai::node> (init, service, data_path, alarm, config.node, opencl_work));
|
||||
auto node (std::make_shared<rai::node> (init, io_ctx, data_path, alarm, config.node, opencl_work));
|
||||
if (!init.error ())
|
||||
{
|
||||
node->flags = flags;
|
||||
node->start ();
|
||||
std::unique_ptr<rai::rpc> rpc = get_rpc (service, *node, config.rpc);
|
||||
std::unique_ptr<rai::rpc> rpc = get_rpc (io_ctx, *node, config.rpc);
|
||||
if (rpc && config.rpc_enable)
|
||||
{
|
||||
rpc->start ();
|
||||
}
|
||||
runner = std::make_unique<rai::thread_runner> (service, node->config.io_threads);
|
||||
runner = std::make_unique<rai::thread_runner> (io_ctx, node->config.io_threads);
|
||||
runner->join ();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -369,7 +369,7 @@ int main (int argc, char * const * argv)
|
|||
rai::logging logging;
|
||||
auto path (rai::unique_path ());
|
||||
logging.init (path);
|
||||
auto node (std::make_shared<rai::node> (init, system.service, 24001, path, system.alarm, logging, work));
|
||||
auto node (std::make_shared<rai::node> (init, system.io_ctx, 24001, path, system.alarm, logging, work));
|
||||
rai::block_hash genesis_latest (node->latest (rai::test_genesis_key.pub));
|
||||
rai::uint128_t genesis_balance (std::numeric_limits<rai::uint128_t>::max ());
|
||||
// Generating keys
|
||||
|
@ -445,7 +445,7 @@ int main (int argc, char * const * argv)
|
|||
rai::logging logging;
|
||||
auto path (rai::unique_path ());
|
||||
logging.init (path);
|
||||
auto node (std::make_shared<rai::node> (init, system.service, 24001, path, system.alarm, logging, work));
|
||||
auto node (std::make_shared<rai::node> (init, system.io_ctx, 24001, path, system.alarm, logging, work));
|
||||
rai::block_hash genesis_latest (node->latest (rai::test_genesis_key.pub));
|
||||
rai::uint128_t genesis_balance (std::numeric_limits<rai::uint128_t>::max ());
|
||||
// Generating keys
|
||||
|
|
|
@ -210,7 +210,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
rai::set_secure_perm_file (config_path, error_chmod);
|
||||
if (!error)
|
||||
{
|
||||
boost::asio::io_service service;
|
||||
boost::asio::io_context io_ctx;
|
||||
config.node.logging.init (data_path);
|
||||
std::shared_ptr<rai::node> node;
|
||||
std::shared_ptr<rai_qt::wallet> gui;
|
||||
|
@ -220,9 +220,9 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
return opencl->generate_work (root_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (rai::uint256_union const &)> (nullptr));
|
||||
rai::alarm alarm (service);
|
||||
rai::alarm alarm (io_ctx);
|
||||
rai::node_init init;
|
||||
node = std::make_shared<rai::node> (init, service, data_path, alarm, config.node, work);
|
||||
node = std::make_shared<rai::node> (init, io_ctx, data_path, alarm, config.node, work);
|
||||
if (!init.error ())
|
||||
{
|
||||
auto wallet (node->wallets.open (config.wallet));
|
||||
|
@ -256,12 +256,12 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
assert (wallet->exists (config.account));
|
||||
update_config (config, config_path, config_file);
|
||||
node->start ();
|
||||
std::unique_ptr<rai::rpc> rpc = get_rpc (service, *node, config.rpc);
|
||||
std::unique_ptr<rai::rpc> rpc = get_rpc (io_ctx, *node, config.rpc);
|
||||
if (rpc && config.rpc_enable)
|
||||
{
|
||||
rpc->start ();
|
||||
}
|
||||
rai::thread_runner runner (service, node->config.io_threads);
|
||||
rai::thread_runner runner (io_ctx, node->config.io_threads);
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&]() {
|
||||
rpc->stop ();
|
||||
node->stop ();
|
||||
|
|
|
@ -20,7 +20,7 @@ TEST (system, generate_mass_activity)
|
|||
TEST (system, generate_mass_activity_long)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
size_t count (1000000000);
|
||||
system.generate_mass_activity (count, *system.nodes[0]);
|
||||
|
@ -39,13 +39,13 @@ TEST (system, receive_while_synchronizing)
|
|||
std::vector<boost::thread> threads;
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads);
|
||||
rai::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
size_t count (1000);
|
||||
system.generate_mass_activity (count, *system.nodes[0]);
|
||||
rai::keypair key;
|
||||
rai::node_init init1;
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
auto node1 (std::make_shared<rai::node> (init1, system.io_ctx, 24001, rai::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
node1->network.send_keepalive (system.nodes[0]->network.endpoint ());
|
||||
auto wallet (node1->wallets.create (1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue