Updating and applying formatting changes. (#3209)
This commit is contained in:
parent
bca5142309
commit
8d0a03e23d
188 changed files with 4409 additions and 4406 deletions
|
|
@ -7,22 +7,23 @@ Standard: Cpp11
|
|||
TabWidth: 4
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Middle
|
||||
UseTab: ForIndentation
|
||||
UseTab: ForContinuationAndIndentation
|
||||
BreakBeforeBraces: Custom
|
||||
AlignEscapedNewlines: Left
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
ContinuationIndentWidth: 0
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
IndentCaseLabels: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterEnum: true
|
||||
AfterStruct: true
|
||||
SplitEmptyFunction: true
|
||||
|
|
@ -33,6 +34,7 @@ BraceWrapping:
|
|||
AfterClass: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
SortIncludes: true
|
||||
|
|
|
|||
|
|
@ -1434,7 +1434,7 @@ TEST (mdb_block_store, upgrade_v16_v17)
|
|||
nano::state_block block2 (nano::dev_genesis_key.pub, block1.hash (), nano::dev_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio - 1, nano::dev_genesis_key.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (block1.hash ()));
|
||||
nano::state_block block3 (nano::dev_genesis_key.pub, block2.hash (), nano::dev_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio - 2, nano::dev_genesis_key.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (block2.hash ()));
|
||||
|
||||
auto code = [&block1, &block2, &block3](auto confirmation_height, nano::block_hash const & expected_cemented_frontier) {
|
||||
auto code = [&block1, &block2, &block3] (auto confirmation_height, nano::block_hash const & expected_cemented_frontier) {
|
||||
auto path (nano::unique_path ());
|
||||
nano::mdb_val value;
|
||||
{
|
||||
|
|
@ -1854,7 +1854,7 @@ TEST (mdb_block_store, upgrade_backup)
|
|||
fs::create_directory (dir);
|
||||
auto path = dir / "data.ldb";
|
||||
/** Returns 'dir' if backup file cannot be found */
|
||||
auto get_backup_path = [&dir]() {
|
||||
auto get_backup_path = [&dir] () {
|
||||
for (fs::directory_iterator itr (dir); itr != fs::directory_iterator (); ++itr)
|
||||
{
|
||||
if (itr->path ().filename ().string ().find ("data_backup_") != std::string::npos)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ TEST (distributed_work, no_peers)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
|
@ -54,7 +54,7 @@ TEST (distributed_work, no_peers_cancel)
|
|||
auto & node = *system.add_node (node_config);
|
||||
nano::block_hash hash{ 1 };
|
||||
bool done{ false };
|
||||
auto callback_to_cancel = [&done](boost::optional<uint64_t> work_a) {
|
||||
auto callback_to_cancel = [&done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_FALSE (work_a.is_initialized ());
|
||||
done = true;
|
||||
};
|
||||
|
|
@ -83,7 +83,7 @@ TEST (distributed_work, no_peers_multi)
|
|||
nano::block_hash hash{ 1 };
|
||||
unsigned total{ 10 };
|
||||
std::atomic<unsigned> count{ 0 };
|
||||
auto callback = [&count](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&count] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
++count;
|
||||
};
|
||||
|
|
@ -127,7 +127,7 @@ TEST (distributed_work, peer)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
|
@ -153,7 +153,7 @@ TEST (distributed_work, peer_malicious)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
|
@ -193,7 +193,7 @@ TEST (distributed_work, peer_multi)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
|
@ -232,7 +232,7 @@ TEST (distributed_work, fail_resolve)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public:
|
|||
{
|
||||
if (socket->is_open ())
|
||||
{
|
||||
socket->async_close (boost::beast::websocket::close_code::normal, [socket = this->socket](boost::beast::error_code const & ec) {
|
||||
socket->async_close (boost::beast::websocket::close_code::normal, [socket = this->socket] (boost::beast::error_code const & ec) {
|
||||
// A synchronous close usually hangs in tests when the server's io_context stops looping
|
||||
// An async_close solves this problem
|
||||
});
|
||||
|
|
@ -55,7 +55,7 @@ public:
|
|||
debug_assert (deadline > 0s);
|
||||
boost::optional<std::string> result;
|
||||
auto buffer (std::make_shared<boost::beast::flat_buffer> ());
|
||||
socket->async_read (*buffer, [&result, &buffer, socket = this->socket](boost::beast::error_code const & ec, std::size_t const /*n*/) {
|
||||
socket->async_read (*buffer, [&result, &buffer, socket = this->socket] (boost::beast::error_code const & ec, std::size_t const /*n*/) {
|
||||
if (!ec)
|
||||
{
|
||||
std::ostringstream res;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class work_peer_connection : public std::enable_shared_from_this<work_peer_conne
|
|||
const std::string generic_error = "Unable to parse JSON";
|
||||
|
||||
public:
|
||||
work_peer_connection (asio::io_context & ioc_a, work_peer_type const type_a, nano::work_version const version_a, nano::work_pool & pool_a, std::function<void(bool const)> on_generation_a, std::function<void()> on_cancel_a) :
|
||||
work_peer_connection (asio::io_context & ioc_a, work_peer_type const type_a, nano::work_version const version_a, nano::work_pool & pool_a, std::function<void (bool const)> on_generation_a, std::function<void ()> on_cancel_a) :
|
||||
socket (ioc_a),
|
||||
type (type_a),
|
||||
version (version_a),
|
||||
|
|
@ -58,14 +58,14 @@ private:
|
|||
beast::flat_buffer buffer{ 8192 };
|
||||
http::request<http::string_body> request;
|
||||
http::response<http::dynamic_body> response;
|
||||
std::function<void(bool const)> on_generation;
|
||||
std::function<void()> on_cancel;
|
||||
std::function<void (bool const)> on_generation;
|
||||
std::function<void ()> on_cancel;
|
||||
asio::deadline_timer timer;
|
||||
|
||||
void read_request ()
|
||||
{
|
||||
auto this_l = shared_from_this ();
|
||||
http::async_read (socket, buffer, request, [this_l](beast::error_code ec, std::size_t const /*size_a*/) {
|
||||
http::async_read (socket, buffer, request, [this_l] (beast::error_code ec, std::size_t const /*size_a*/) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->process_request ();
|
||||
|
|
@ -110,7 +110,7 @@ private:
|
|||
{
|
||||
auto this_l = shared_from_this ();
|
||||
response.content_length (response.body ().size ());
|
||||
http::async_write (socket, response, [this_l](beast::error_code ec, std::size_t /*size_a*/) {
|
||||
http::async_write (socket, response, [this_l] (beast::error_code ec, std::size_t /*size_a*/) {
|
||||
this_l->socket.shutdown (tcp::socket::shutdown_send, ec);
|
||||
this_l->socket.close ();
|
||||
});
|
||||
|
|
@ -143,7 +143,7 @@ private:
|
|||
auto hash = hash_a;
|
||||
auto request_difficulty = nano::work_threshold_base (version);
|
||||
auto this_l (shared_from_this ());
|
||||
work_pool.generate (version, hash, request_difficulty, [this_l, hash](boost::optional<uint64_t> work_a) {
|
||||
work_pool.generate (version, hash, request_difficulty, [this_l, hash] (boost::optional<uint64_t> work_a) {
|
||||
auto result = work_a.value_or (0);
|
||||
auto result_difficulty (nano::work_difficulty (this_l->version, hash, result));
|
||||
static nano::network_params params;
|
||||
|
|
@ -157,7 +157,7 @@ private:
|
|||
beast::ostream (this_l->response.body ()) << ostream.str ();
|
||||
// Delay response by 500ms as a slow peer, immediate async call for a good peer
|
||||
this_l->timer.expires_from_now (boost::posix_time::milliseconds (this_l->type == work_peer_type::slow ? 500 : 0));
|
||||
this_l->timer.async_wait ([this_l, result](const boost::system::error_code & ec) {
|
||||
this_l->timer.async_wait ([this_l, result] (const boost::system::error_code & ec) {
|
||||
if (this_l->on_generation)
|
||||
{
|
||||
this_l->on_generation (result != 0);
|
||||
|
|
@ -226,7 +226,7 @@ private:
|
|||
std::weak_ptr<fake_work_peer> this_w (shared_from_this ());
|
||||
auto connection (std::make_shared<work_peer_connection> (
|
||||
ioc, type, version, pool,
|
||||
[this_w](bool const good_generation) {
|
||||
[this_w] (bool const good_generation) {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
if (good_generation)
|
||||
|
|
@ -239,13 +239,13 @@ private:
|
|||
}
|
||||
};
|
||||
},
|
||||
[this_w]() {
|
||||
[this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
++this_l->cancels;
|
||||
}
|
||||
}));
|
||||
acceptor.async_accept (connection->socket, [connection, this_w](beast::error_code ec) {
|
||||
acceptor.async_accept (connection->socket, [connection, this_w] (beast::error_code ec) {
|
||||
if (!ec)
|
||||
{
|
||||
if (auto this_l = this_w.lock ())
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ TEST (frontiers_confirmation, prioritize_frontiers)
|
|||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
constexpr auto num_accounts = 5;
|
||||
auto priority_orders_match = [](auto const & cementable_frontiers, auto const & desired_order) {
|
||||
return std::equal (desired_order.begin (), desired_order.end (), cementable_frontiers.template get<1> ().begin (), cementable_frontiers.template get<1> ().end (), [](nano::account const & account, nano::cementable_account const & cementable_account) {
|
||||
auto priority_orders_match = [] (auto const & cementable_frontiers, auto const & desired_order) {
|
||||
return std::equal (desired_order.begin (), desired_order.end (), cementable_frontiers.template get<1> ().begin (), cementable_frontiers.template get<1> ().end (), [] (nano::account const & account, nano::cementable_account const & cementable_account) {
|
||||
return (account == cementable_account.account);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ TEST (ipc, asynchronous)
|
|||
auto req (nano::ipc::prepare_request (nano::ipc::payload_encoding::json_v1, std::string (R"({"action": "block_count"})")));
|
||||
auto res (std::make_shared<std::vector<uint8_t>> ());
|
||||
std::atomic<bool> call_completed{ false };
|
||||
client.async_connect ("::1", 24077, [&client, &req, &res, &call_completed](nano::error err) {
|
||||
client.async_write (req, [&client, &req, &res, &call_completed](nano::error err_a, size_t size_a) {
|
||||
client.async_connect ("::1", 24077, [&client, &req, &res, &call_completed] (nano::error err) {
|
||||
client.async_write (req, [&client, &req, &res, &call_completed] (nano::error err_a, size_t size_a) {
|
||||
ASSERT_NO_ERROR (static_cast<std::error_code> (err_a));
|
||||
ASSERT_EQ (size_a, req.size ());
|
||||
// Read length
|
||||
client.async_read (res, sizeof (uint32_t), [&client, &res, &call_completed](nano::error err_read_a, size_t size_read_a) {
|
||||
client.async_read (res, sizeof (uint32_t), [&client, &res, &call_completed] (nano::error err_read_a, size_t size_read_a) {
|
||||
ASSERT_NO_ERROR (static_cast<std::error_code> (err_read_a));
|
||||
ASSERT_EQ (size_read_a, sizeof (uint32_t));
|
||||
uint32_t payload_size_l = boost::endian::big_to_native (*reinterpret_cast<uint32_t *> (res->data ()));
|
||||
// Read json payload
|
||||
client.async_read (res, payload_size_l, [&res, &call_completed](nano::error err_read_a, size_t size_read_a) {
|
||||
client.async_read (res, payload_size_l, [&res, &call_completed] (nano::error err_read_a, size_t size_read_a) {
|
||||
std::string payload (res->begin (), res->end ());
|
||||
std::stringstream ss;
|
||||
ss << payload;
|
||||
|
|
@ -68,7 +68,7 @@ TEST (ipc, synchronous)
|
|||
|
||||
// Start blocking IPC client in a separate thread
|
||||
std::atomic<bool> call_completed{ false };
|
||||
std::thread client_thread ([&client, &call_completed]() {
|
||||
std::thread client_thread ([&client, &call_completed] () {
|
||||
client.connect ("::1", 24077);
|
||||
std::string response (nano::ipc::request (nano::ipc::payload_encoding::json_v1, client, std::string (R"({"action": "block_count"})")));
|
||||
std::stringstream ss;
|
||||
|
|
|
|||
|
|
@ -3081,7 +3081,7 @@ TEST (ledger, work_validation)
|
|||
nano::keypair key;
|
||||
|
||||
// With random work the block doesn't pass, then modifies the block with sufficient work and ensures a correct result
|
||||
auto process_block = [&store, &ledger, &pool](nano::block & block_a, nano::block_details const details_a) {
|
||||
auto process_block = [&store, &ledger, &pool] (nano::block & block_a, nano::block_details const details_a) {
|
||||
auto threshold = nano::work_threshold (block_a.work_version (), details_a);
|
||||
// Rarely failed with random work, so modify until it doesn't have enough difficulty
|
||||
while (block_a.difficulty () >= threshold)
|
||||
|
|
@ -3289,7 +3289,7 @@ TEST (ledger, cache)
|
|||
auto genesis_weight = nano::genesis_amount - i;
|
||||
auto pruned_count = i;
|
||||
|
||||
auto cache_check = [&, i](nano::ledger_cache const & cache_a) {
|
||||
auto cache_check = [&, i] (nano::ledger_cache const & cache_a) {
|
||||
ASSERT_EQ (account_count, cache_a.account_count);
|
||||
ASSERT_EQ (block_count, cache_a.block_count);
|
||||
ASSERT_EQ (cemented_count, cache_a.cemented_count);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ TEST (locks, condition_variable_wait_until)
|
|||
|
||||
nano::condition_variable cv;
|
||||
nano::mutex mutex;
|
||||
auto impl = [&](auto time_to_sleep) {
|
||||
auto impl = [&] (auto time_to_sleep) {
|
||||
std::atomic<bool> notified{ false };
|
||||
std::atomic<bool> finished{ false };
|
||||
nano::unique_lock<nano::mutex> lk (mutex);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ TEST (network, tcp_connection)
|
|||
std::atomic<bool> done1 (false);
|
||||
std::string message1;
|
||||
acceptor.async_accept (incoming,
|
||||
[&done1, &message1](boost::system::error_code const & ec_a) {
|
||||
[&done1, &message1] (boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
message1 = ec_a.message ();
|
||||
|
|
@ -36,7 +36,7 @@ TEST (network, tcp_connection)
|
|||
std::atomic<bool> done2 (false);
|
||||
std::string message2;
|
||||
connector.async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v4::loopback (), port),
|
||||
[&done2, &message2](boost::system::error_code const & ec_a) {
|
||||
[&done2, &message2] (boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
message2 = ec_a.message ();
|
||||
|
|
@ -283,7 +283,7 @@ TEST (network, send_insufficient_work_udp)
|
|||
auto block (std::make_shared<nano::send_block> (0, 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, 0));
|
||||
nano::publish publish (block);
|
||||
nano::transport::channel_udp channel (node1.network.udp_channels, node2.network.endpoint (), node1.network_params.protocol.protocol_version);
|
||||
channel.send (publish, [](boost::system::error_code const & ec, size_t size) {});
|
||||
channel.send (publish, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
|
|
@ -298,27 +298,27 @@ TEST (network, send_insufficient_work)
|
|||
auto block1 (std::make_shared<nano::send_block> (0, 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, 0));
|
||||
nano::publish publish1 (block1);
|
||||
auto tcp_channel (node1.network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node2.network.endpoint ())));
|
||||
tcp_channel->send (publish1, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish1, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
// Legacy block work between epoch_2_recieve & epoch_1
|
||||
auto block2 (std::make_shared<nano::send_block> (block1->hash (), 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, system.work_generate_limited (block1->hash (), node1.network_params.network.publish_thresholds.epoch_2_receive, node1.network_params.network.publish_thresholds.epoch_1 - 1)));
|
||||
nano::publish publish2 (block2);
|
||||
tcp_channel->send (publish2, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish2, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 1);
|
||||
ASSERT_EQ (2, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
// Legacy block work epoch_1
|
||||
auto block3 (std::make_shared<nano::send_block> (block2->hash (), 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *system.work.generate (block2->hash (), node1.network_params.network.publish_thresholds.epoch_2)));
|
||||
nano::publish publish3 (block3);
|
||||
tcp_channel->send (publish3, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish3, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in));
|
||||
// State block work epoch_2_recieve
|
||||
auto block4 (std::make_shared<nano::state_block> (nano::dev_genesis_key.pub, block1->hash (), nano::dev_genesis_key.pub, 20, 1, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, system.work_generate_limited (block1->hash (), node1.network_params.network.publish_thresholds.epoch_2_receive, node1.network_params.network.publish_thresholds.epoch_1 - 1)));
|
||||
nano::publish publish4 (block4);
|
||||
tcp_channel->send (publish4, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish4, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in));
|
||||
ASSERT_EQ (2, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
|
|
@ -405,7 +405,7 @@ TEST (network, receive_weight_change)
|
|||
system.wallet (1)->store.representative_set (transaction, key2.pub);
|
||||
}
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::dev_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->weight (key2.pub) == system.nodes[0]->config.receive_minimum.number (); }));
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr<nano::node> const & node_a) { return node_a->weight (key2.pub) == system.nodes[0]->config.receive_minimum.number (); }));
|
||||
}
|
||||
|
||||
TEST (parse_endpoint, valid)
|
||||
|
|
@ -496,7 +496,7 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
auto finish1 (false);
|
||||
nano::endpoint endpoint3;
|
||||
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) {
|
||||
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;
|
||||
|
|
@ -504,7 +504,7 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
boost::asio::ip::udp::socket socket2 (io_ctx, endpoint2);
|
||||
nano::endpoint endpoint5 (boost::asio::ip::address_v4::loopback (), port1);
|
||||
nano::endpoint endpoint6 (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4::loopback ()), port2);
|
||||
socket2.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint5, [](boost::system::error_code const & error, size_t size_a) {
|
||||
socket2.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint5, [] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
});
|
||||
|
|
@ -518,11 +518,11 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
ASSERT_EQ (endpoint6, endpoint3);
|
||||
std::array<uint8_t, 16> bytes2;
|
||||
nano::endpoint endpoint4;
|
||||
socket2.async_receive_from (boost::asio::buffer (bytes2.data (), bytes2.size ()), endpoint4, [](boost::system::error_code const & error, size_t size_a) {
|
||||
socket2.async_receive_from (boost::asio::buffer (bytes2.data (), bytes2.size ()), endpoint4, [] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (!error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
});
|
||||
socket1.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint6, [](boost::system::error_code const & error, size_t size_a) {
|
||||
socket1.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint6, [] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
});
|
||||
|
|
@ -635,7 +635,7 @@ TEST (message_buffer_manager, one_buffer_multithreaded)
|
|||
{
|
||||
nano::stat stats;
|
||||
nano::message_buffer_manager buffer (stats, 512, 1);
|
||||
boost::thread thread ([&buffer]() {
|
||||
boost::thread thread ([&buffer] () {
|
||||
auto done (false);
|
||||
while (!done)
|
||||
{
|
||||
|
|
@ -663,7 +663,7 @@ TEST (message_buffer_manager, many_buffers_multithreaded)
|
|||
std::vector<boost::thread> threads;
|
||||
for (auto i (0); i < 4; ++i)
|
||||
{
|
||||
threads.push_back (boost::thread ([&buffer]() {
|
||||
threads.push_back (boost::thread ([&buffer] () {
|
||||
auto done (false);
|
||||
while (!done)
|
||||
{
|
||||
|
|
@ -679,7 +679,7 @@ TEST (message_buffer_manager, many_buffers_multithreaded)
|
|||
std::atomic_int count (0);
|
||||
for (auto i (0); i < 4; ++i)
|
||||
{
|
||||
threads.push_back (boost::thread ([&buffer, &count]() {
|
||||
threads.push_back (boost::thread ([&buffer, &count] () {
|
||||
auto done (false);
|
||||
for (auto i (0); !done && i < 1000; ++i)
|
||||
{
|
||||
|
|
@ -723,9 +723,9 @@ TEST (tcp_listener, tcp_node_id_handshake)
|
|||
nano::node_id_handshake node_id_handshake (cookie, boost::none);
|
||||
auto input (node_id_handshake.to_shared_const_buffer ());
|
||||
std::atomic<bool> write_done (false);
|
||||
socket->async_connect (bootstrap_endpoint, [&input, socket, &write_done](boost::system::error_code const & ec) {
|
||||
socket->async_connect (bootstrap_endpoint, [&input, socket, &write_done] (boost::system::error_code const & ec) {
|
||||
ASSERT_FALSE (ec);
|
||||
socket->async_write (input, [&input, &write_done](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_write (input, [&input, &write_done] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (input.size (), size_a);
|
||||
write_done = true;
|
||||
|
|
@ -738,7 +738,7 @@ TEST (tcp_listener, tcp_node_id_handshake)
|
|||
nano::node_id_handshake node_id_handshake_response (boost::none, response_zero);
|
||||
auto output (node_id_handshake_response.to_bytes ());
|
||||
std::atomic<bool> done (false);
|
||||
socket->async_read (output, output->size (), [&output, &done](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (output, output->size (), [&output, &done] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (output->size (), size_a);
|
||||
done = true;
|
||||
|
|
@ -752,7 +752,7 @@ TEST (tcp_listener, tcp_listener_timeout_empty)
|
|||
auto node0 (system.nodes[0]);
|
||||
auto socket (std::make_shared<nano::socket> (*node0));
|
||||
std::atomic<bool> connected (false);
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&connected](boost::system::error_code const & ec) {
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&connected] (boost::system::error_code const & ec) {
|
||||
ASSERT_FALSE (ec);
|
||||
connected = true;
|
||||
});
|
||||
|
|
@ -777,9 +777,9 @@ TEST (tcp_listener, tcp_listener_timeout_node_id_handshake)
|
|||
auto cookie (node0->network.syn_cookies.assign (nano::transport::map_tcp_to_endpoint (node0->bootstrap.endpoint ())));
|
||||
nano::node_id_handshake node_id_handshake (cookie, boost::none);
|
||||
auto input (node_id_handshake.to_shared_const_buffer ());
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&input, socket](boost::system::error_code const & ec) {
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&input, socket] (boost::system::error_code const & ec) {
|
||||
ASSERT_FALSE (ec);
|
||||
socket->async_write (input, [&input](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_write (input, [&input] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (input.size (), size_a);
|
||||
});
|
||||
|
|
@ -818,7 +818,7 @@ TEST (network, replace_port)
|
|||
auto wrong_endpoint = nano::endpoint (node1->network.endpoint ().address (), nano::get_available_port ());
|
||||
auto channel0 (node0->network.udp_channels.insert (wrong_endpoint, node1->network_params.protocol.protocol_version));
|
||||
ASSERT_NE (nullptr, channel0);
|
||||
node0->network.udp_channels.modify (channel0, [&node1](std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
node0->network.udp_channels.modify (channel0, [&node1] (std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
channel_a->set_node_id (node1->node_id.pub);
|
||||
});
|
||||
auto peers_list (node0->network.list (std::numeric_limits<size_t>::max ()));
|
||||
|
|
@ -960,7 +960,7 @@ TEST (peer_exclusion, validate)
|
|||
nano::tcp_endpoint oldest (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4 (0x0)), 0);
|
||||
ASSERT_EQ (peers_by_endpoint.end (), peers_by_endpoint.find (oldest.address ()));
|
||||
|
||||
auto to_seconds = [](std::chrono::steady_clock::time_point const & timepoint) {
|
||||
auto to_seconds = [] (std::chrono::steady_clock::time_point const & timepoint) {
|
||||
return static_cast<double> (std::chrono::duration_cast<std::chrono::seconds> (timepoint.time_since_epoch ()).count ());
|
||||
};
|
||||
nano::tcp_endpoint first (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4 (0x1)), 0);
|
||||
|
|
@ -1117,7 +1117,7 @@ TEST (network, cleanup_purge)
|
|||
ASSERT_EQ (0, node1.network.size ());
|
||||
|
||||
std::weak_ptr<nano::node> node_w = node1.shared ();
|
||||
node1.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w](std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
node1.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w] (std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.send_keepalive (channel_a);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ TEST (network_filter, unit)
|
|||
{
|
||||
nano::genesis genesis;
|
||||
nano::network_filter filter (1);
|
||||
auto one_block = [&filter](std::shared_ptr<nano::block> const & block_a, bool expect_duplicate_a) {
|
||||
auto one_block = [&filter] (std::shared_ptr<nano::block> const & block_a, bool expect_duplicate_a) {
|
||||
nano::publish message (block_a);
|
||||
auto bytes (message.to_bytes ());
|
||||
nano::bufferstream stream (bytes->data (), bytes->size ());
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ TEST (node, send_single_observing_peer)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::dev_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), system.nodes[0]->balance (nano::dev_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return !node_a->balance (key2.pub).is_zero (); }));
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr<nano::node> const & node_a) { return !node_a->balance (key2.pub).is_zero (); }));
|
||||
}
|
||||
|
||||
TEST (node, send_single_many_peers)
|
||||
|
|
@ -172,7 +172,7 @@ TEST (node, send_single_many_peers)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::dev_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), system.nodes[0]->balance (nano::dev_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
ASSERT_TIMELY (3.5min, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return !node_a->balance (key2.pub).is_zero (); }));
|
||||
ASSERT_TIMELY (3.5min, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr<nano::node> const & node_a) { return !node_a->balance (key2.pub).is_zero (); }));
|
||||
system.stop ();
|
||||
for (auto node : system.nodes)
|
||||
{
|
||||
|
|
@ -212,7 +212,7 @@ TEST (node, send_out_of_order)
|
|||
node1.process_active (send3);
|
||||
node1.process_active (send2);
|
||||
node1.process_active (send1);
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->balance (nano::dev_genesis_key.pub) == nano::genesis_amount - node1.config.receive_minimum.number () * 3; }));
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr<nano::node> const & node_a) { return node_a->balance (nano::dev_genesis_key.pub) == nano::genesis_amount - node1.config.receive_minimum.number () * 3; }));
|
||||
}
|
||||
|
||||
TEST (node, quick_confirm)
|
||||
|
|
@ -539,7 +539,7 @@ TEST (node, connect_after_junk)
|
|||
std::vector<uint8_t> junk_buffer;
|
||||
junk_buffer.push_back (0);
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
channel1->send_buffer (nano::shared_const_buffer (std::move (junk_buffer)), [](boost::system::error_code const &, size_t) {});
|
||||
channel1->send_buffer (nano::shared_const_buffer (std::move (junk_buffer)), [] (boost::system::error_code const &, size_t) {});
|
||||
ASSERT_TIMELY (10s, node0->stats.count (nano::stat::type::error) != 0);
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
|
|
@ -560,11 +560,11 @@ TEST (node, price)
|
|||
nano::system system (1);
|
||||
auto price1 (system.nodes[0]->price (nano::Gxrb_ratio, 1));
|
||||
ASSERT_EQ (nano::node::price_max * 100.0, price1);
|
||||
auto price2 (system.nodes[0]->price (nano::Gxrb_ratio * int(nano::node::free_cutoff + 1), 1));
|
||||
auto price2 (system.nodes[0]->price (nano::Gxrb_ratio * int (nano::node::free_cutoff + 1), 1));
|
||||
ASSERT_EQ (0, price2);
|
||||
auto price3 (system.nodes[0]->price (nano::Gxrb_ratio * int(nano::node::free_cutoff + 2) / 2, 1));
|
||||
auto price3 (system.nodes[0]->price (nano::Gxrb_ratio * int (nano::node::free_cutoff + 2) / 2, 1));
|
||||
ASSERT_EQ (nano::node::price_max * 100.0 / 2, price3);
|
||||
auto price4 (system.nodes[0]->price (nano::Gxrb_ratio * int(nano::node::free_cutoff) * 2, 1));
|
||||
auto price4 (system.nodes[0]->price (nano::Gxrb_ratio * int (nano::node::free_cutoff) * 2, 1));
|
||||
ASSERT_EQ (0, price4);
|
||||
}
|
||||
|
||||
|
|
@ -943,7 +943,7 @@ TEST (json, backup)
|
|||
ASSERT_EQ ("created", object1.text);
|
||||
|
||||
/** Returns 'dir' if backup file cannot be found */
|
||||
auto get_backup_path = [&dir]() {
|
||||
auto get_backup_path = [&dir] () {
|
||||
for (fs::directory_iterator itr (dir); itr != fs::directory_iterator (); ++itr)
|
||||
{
|
||||
if (itr->path ().filename ().string ().find ("_backup_") != std::string::npos)
|
||||
|
|
@ -954,7 +954,7 @@ TEST (json, backup)
|
|||
return dir;
|
||||
};
|
||||
|
||||
auto get_file_count = [&dir]() {
|
||||
auto get_file_count = [&dir] () {
|
||||
return std::count_if (boost::filesystem::directory_iterator (dir), boost::filesystem::directory_iterator (), static_cast<bool (*) (const boost::filesystem::path &)> (boost::filesystem::is_regular_file));
|
||||
};
|
||||
|
||||
|
|
@ -1492,7 +1492,7 @@ TEST (node, coherent_observer)
|
|||
{
|
||||
nano::system system (1);
|
||||
auto & node1 (*system.nodes[0]);
|
||||
node1.observers.blocks.add ([&node1](nano::election_status const & status_a, std::vector<nano::vote_with_weight_info> const &, nano::account const &, nano::uint128_t const &, bool) {
|
||||
node1.observers.blocks.add ([&node1] (nano::election_status const & status_a, std::vector<nano::vote_with_weight_info> const &, nano::account const &, nano::uint128_t const &, bool) {
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
ASSERT_TRUE (node1.store.block_exists (transaction, status_a.winner->hash ()));
|
||||
});
|
||||
|
|
@ -2269,7 +2269,7 @@ TEST (node, rep_remove)
|
|||
ASSERT_EQ (*channel0, reps[0].channel_ref ());
|
||||
// Modify last_packet_received so the channel is removed faster
|
||||
std::chrono::steady_clock::time_point fake_timepoint{};
|
||||
node.network.udp_channels.modify (channel_udp, [fake_timepoint](std::shared_ptr<nano::transport::channel_udp> const & channel_a) {
|
||||
node.network.udp_channels.modify (channel_udp, [fake_timepoint] (std::shared_ptr<nano::transport::channel_udp> const & channel_a) {
|
||||
channel_a->set_last_packet_received (fake_timepoint);
|
||||
});
|
||||
// This UDP channel is not reachable and should timeout
|
||||
|
|
@ -2287,7 +2287,7 @@ TEST (node, rep_remove)
|
|||
auto node2 (std::make_shared<nano::node> (system.io_ctx, nano::unique_path (), nano::node_config (nano::get_available_port (), system.logging), system.work));
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
auto vote3 = std::make_shared<nano::vote> (keypair2.pub, keypair2.prv, 0, genesis.open);
|
||||
node.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w, &vote3](std::shared_ptr<nano::transport::channel> const & channel2) {
|
||||
node.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w, &vote3] (std::shared_ptr<nano::transport::channel> const & channel2) {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
ASSERT_FALSE (node_l->rep_crawler.response (channel2, vote3));
|
||||
|
|
@ -2358,7 +2358,7 @@ TEST (node, balance_observer)
|
|||
auto & node1 (*system.nodes[0]);
|
||||
std::atomic<int> balances (0);
|
||||
nano::keypair key;
|
||||
node1.observers.account_balance.add ([&key, &balances](nano::account const & account_a, bool is_pending) {
|
||||
node1.observers.account_balance.add ([&key, &balances] (nano::account const & account_a, bool is_pending) {
|
||||
if (key.pub == account_a && is_pending)
|
||||
{
|
||||
balances++;
|
||||
|
|
@ -2990,7 +2990,7 @@ TEST (node, vote_by_hash_bundle)
|
|||
nano::keypair key1;
|
||||
system.wallet (0)->insert_adhoc (key1.prv);
|
||||
|
||||
system.nodes[0]->observers.vote.add ([&max_hashes](std::shared_ptr<nano::vote> const & vote_a, std::shared_ptr<nano::transport::channel> const &, nano::vote_code) {
|
||||
system.nodes[0]->observers.vote.add ([&max_hashes] (std::shared_ptr<nano::vote> const & vote_a, std::shared_ptr<nano::transport::channel> const &, nano::vote_code) {
|
||||
if (vote_a->blocks.size () > max_hashes)
|
||||
{
|
||||
max_hashes = vote_a->blocks.size ();
|
||||
|
|
@ -3723,7 +3723,7 @@ TEST (node, dont_write_lock_node)
|
|||
|
||||
std::promise<void> write_lock_held_promise;
|
||||
std::promise<void> finished_promise;
|
||||
std::thread ([&path, &write_lock_held_promise, &finished_promise]() {
|
||||
std::thread ([&path, &write_lock_held_promise, &finished_promise] () {
|
||||
nano::logger_mt logger;
|
||||
auto store = nano::make_store (logger, path, false, true);
|
||||
{
|
||||
|
|
@ -3867,7 +3867,7 @@ TEST (node, aggressive_flooding)
|
|||
bool const sanitizer_or_valgrind (is_sanitizer_build || nano::running_within_valgrind ());
|
||||
nodes_wallets.resize (!sanitizer_or_valgrind ? 5 : 3);
|
||||
|
||||
std::generate (nodes_wallets.begin (), nodes_wallets.end (), [&system, node_flags]() {
|
||||
std::generate (nodes_wallets.begin (), nodes_wallets.end (), [&system, node_flags] () {
|
||||
nano::node_config node_config (nano::get_available_port (), system.logging);
|
||||
auto node (system.add_node (node_config, node_flags));
|
||||
return std::make_pair (node, system.wallet (system.nodes.size () - 1));
|
||||
|
|
@ -3920,8 +3920,8 @@ TEST (node, aggressive_flooding)
|
|||
// Processing locally goes through the aggressive block flooding path
|
||||
node1.process_local (block, false);
|
||||
|
||||
auto all_have_block = [&nodes_wallets](nano::block_hash const & hash_a) {
|
||||
return std::all_of (nodes_wallets.begin (), nodes_wallets.end (), [hash = hash_a](auto const & node_wallet) {
|
||||
auto all_have_block = [&nodes_wallets] (nano::block_hash const & hash_a) {
|
||||
return std::all_of (nodes_wallets.begin (), nodes_wallets.end (), [hash = hash_a] (auto const & node_wallet) {
|
||||
return node_wallet.first->block (hash) != nullptr;
|
||||
});
|
||||
};
|
||||
|
|
@ -3957,7 +3957,7 @@ TEST (active_difficulty, recalculate_work)
|
|||
// Process as local block
|
||||
node1.process_active (send1);
|
||||
ASSERT_TIMELY (2s, !node1.active.empty ());
|
||||
auto sum (std::accumulate (node1.active.multipliers_cb.begin (), node1.active.multipliers_cb.end (), double(0)));
|
||||
auto sum (std::accumulate (node1.active.multipliers_cb.begin (), node1.active.multipliers_cb.end (), double (0)));
|
||||
ASSERT_EQ (node1.active.active_difficulty (), nano::difficulty::from_multiplier (sum / node1.active.multipliers_cb.size (), node1.network_params.network.publish_thresholds.epoch_2));
|
||||
nano::unique_lock<nano::mutex> lock (node1.active.mutex);
|
||||
// Fake history records to force work recalculation
|
||||
|
|
@ -3968,7 +3968,7 @@ TEST (active_difficulty, recalculate_work)
|
|||
node1.work_generate_blocking (*send1);
|
||||
node1.process_active (send1);
|
||||
node1.active.update_active_multiplier (lock);
|
||||
sum = std::accumulate (node1.active.multipliers_cb.begin (), node1.active.multipliers_cb.end (), double(0));
|
||||
sum = std::accumulate (node1.active.multipliers_cb.begin (), node1.active.multipliers_cb.end (), double (0));
|
||||
ASSERT_EQ (node1.active.trended_active_multiplier.load (), sum / node1.active.multipliers_cb.size ());
|
||||
lock.unlock ();
|
||||
}
|
||||
|
|
@ -4246,7 +4246,7 @@ TEST (node, dependency_graph)
|
|||
nano::lock_guard<nano::mutex> guard (node.active.mutex);
|
||||
|
||||
// Ensure that active blocks have their ancestors confirmed
|
||||
auto error = std::any_of (dependency_graph.cbegin (), dependency_graph.cend (), [&](auto entry) {
|
||||
auto error = std::any_of (dependency_graph.cbegin (), dependency_graph.cend (), [&] (auto entry) {
|
||||
if (node.active.blocks.count (entry.first))
|
||||
{
|
||||
for (auto ancestor : entry.second)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ TEST (peer_container, no_recontact)
|
|||
auto observed_disconnect (false);
|
||||
nano::endpoint endpoint1 (boost::asio::ip::address_v6::loopback (), 10000);
|
||||
ASSERT_EQ (0, network.size ());
|
||||
network.channel_observer = [&observed_peer](std::shared_ptr<nano::transport::channel> const &) { ++observed_peer; };
|
||||
node1.network.disconnect_observer = [&observed_disconnect]() { observed_disconnect = true; };
|
||||
network.channel_observer = [&observed_peer] (std::shared_ptr<nano::transport::channel> const &) { ++observed_peer; };
|
||||
node1.network.disconnect_observer = [&observed_disconnect] () { observed_disconnect = true; };
|
||||
auto channel (network.udp_channels.insert (endpoint1, node1.network_params.protocol.protocol_version));
|
||||
ASSERT_EQ (1, network.size ());
|
||||
ASSERT_EQ (channel, network.udp_channels.insert (endpoint1, node1.network_params.protocol.protocol_version));
|
||||
|
|
@ -61,12 +61,12 @@ TEST (peer_container, split)
|
|||
nano::endpoint endpoint2 (boost::asio::ip::address_v6::loopback (), 101);
|
||||
auto channel1 (node1.network.udp_channels.insert (endpoint1, 0));
|
||||
ASSERT_NE (nullptr, channel1);
|
||||
node1.network.udp_channels.modify (channel1, [&now](auto channel) {
|
||||
node1.network.udp_channels.modify (channel1, [&now] (auto channel) {
|
||||
channel->set_last_packet_received (now - std::chrono::seconds (1));
|
||||
});
|
||||
auto channel2 (node1.network.udp_channels.insert (endpoint2, 0));
|
||||
ASSERT_NE (nullptr, channel2);
|
||||
node1.network.udp_channels.modify (channel2, [&now](auto channel) {
|
||||
node1.network.udp_channels.modify (channel2, [&now] (auto channel) {
|
||||
channel->set_last_packet_received (now + std::chrono::seconds (1));
|
||||
});
|
||||
ASSERT_EQ (2, node1.network.size ());
|
||||
|
|
@ -84,7 +84,7 @@ TEST (channels, fill_random_clear)
|
|||
std::array<nano::endpoint, 8> target;
|
||||
std::fill (target.begin (), target.end (), nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
|
||||
system.nodes[0]->network.random_fill (target);
|
||||
ASSERT_TRUE (std::all_of (target.begin (), target.end (), [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
ASSERT_TRUE (std::all_of (target.begin (), target.end (), [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
}
|
||||
|
||||
TEST (channels, fill_random_full)
|
||||
|
|
@ -97,7 +97,7 @@ TEST (channels, fill_random_full)
|
|||
std::array<nano::endpoint, 8> target;
|
||||
std::fill (target.begin (), target.end (), nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
|
||||
system.nodes[0]->network.random_fill (target);
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.end (), [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.end (), [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
}
|
||||
|
||||
TEST (channels, fill_random_part)
|
||||
|
|
@ -111,9 +111,9 @@ TEST (channels, fill_random_part)
|
|||
}
|
||||
std::fill (target.begin (), target.end (), nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
|
||||
system.nodes[0]->network.random_fill (target);
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 0); }));
|
||||
ASSERT_TRUE (std::all_of (target.begin () + half, target.end (), [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 0); }));
|
||||
ASSERT_TRUE (std::all_of (target.begin () + half, target.end (), [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
}
|
||||
|
||||
TEST (peer_container, list_fanout)
|
||||
|
|
@ -125,7 +125,7 @@ TEST (peer_container, list_fanout)
|
|||
ASSERT_EQ (0, node.network.fanout ());
|
||||
auto list1 (node.network.list (node.network.fanout ()));
|
||||
ASSERT_TRUE (list1.empty ());
|
||||
auto add_peer = [&node](const uint16_t port_a) {
|
||||
auto add_peer = [&node] (const uint16_t port_a) {
|
||||
ASSERT_NE (nullptr, node.network.udp_channels.insert (nano::endpoint (boost::asio::ip::address_v6::loopback (), port_a), node.network_params.protocol.protocol_version));
|
||||
};
|
||||
add_peer (9998);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
TEST (processor_service, bad_send_signature)
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ TEST (signature_checker, bulk_single_thread)
|
|||
}
|
||||
nano::signature_check_set check = { size, messages.data (), lengths.data (), pub_keys.data (), signatures.data (), verifications.data () };
|
||||
checker.verify (check);
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [](auto verification) { return verification == 1; });
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [] (auto verification) { return verification == 1; });
|
||||
ASSERT_TRUE (all_valid);
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ TEST (signature_checker, many_multi_threaded)
|
|||
{
|
||||
nano::signature_checker checker (4);
|
||||
|
||||
auto signature_checker_work_func = [&checker]() {
|
||||
auto signature_checker_work_func = [&checker] () {
|
||||
nano::keypair key;
|
||||
nano::state_block block (key.pub, 0, key.pub, 0, 0, key.prv, key.pub, 0);
|
||||
auto block_hash = block.hash ();
|
||||
|
|
@ -97,7 +97,7 @@ TEST (signature_checker, many_multi_threaded)
|
|||
checker.verify (signature_checker_sets[i]);
|
||||
|
||||
// Confirm all but last are valid
|
||||
auto all_valid = std::all_of (verifications[i].cbegin (), verifications[i].cend () - 1, [](auto verification) { return verification == 1; });
|
||||
auto all_valid = std::all_of (verifications[i].cbegin (), verifications[i].cend () - 1, [] (auto verification) { return verification == 1; });
|
||||
ASSERT_TRUE (all_valid);
|
||||
ASSERT_EQ (verifications[i][last_signature_index], 0);
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ TEST (signature_checker, one)
|
|||
{
|
||||
nano::signature_checker checker (0);
|
||||
|
||||
auto verify_block = [&checker](auto & block, auto result) {
|
||||
auto verify_block = [&checker] (auto & block, auto result) {
|
||||
std::vector<nano::uint256_union> hashes;
|
||||
std::vector<unsigned char const *> messages;
|
||||
std::vector<size_t> lengths;
|
||||
|
|
@ -152,7 +152,7 @@ TEST (signature_checker, boundary_checks)
|
|||
{
|
||||
// sizes container must be in incrementing order
|
||||
std::vector<size_t> sizes{ 0, 1 };
|
||||
auto add_boundary = [&sizes](size_t boundary) {
|
||||
auto add_boundary = [&sizes] (size_t boundary) {
|
||||
sizes.insert (sizes.end (), { boundary - 1, boundary, boundary + 1 });
|
||||
};
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ TEST (signature_checker, boundary_checks)
|
|||
}
|
||||
nano::signature_check_set check = { size, messages.data (), lengths.data (), pub_keys.data (), signatures.data (), verifications.data () };
|
||||
checker.verify (check);
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [](auto verification) { return verification == 1; });
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [] (auto verification) { return verification == 1; });
|
||||
ASSERT_TRUE (all_valid);
|
||||
last_size = size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ TEST (socket, drop_policy)
|
|||
|
||||
std::vector<std::shared_ptr<nano::socket>> connections;
|
||||
|
||||
auto func = [&](size_t total_message_count, nano::buffer_drop_policy drop_policy) {
|
||||
auto func = [&] (size_t total_message_count, nano::buffer_drop_policy drop_policy) {
|
||||
auto server_port (nano::get_available_port ());
|
||||
boost::asio::ip::tcp::endpoint endpoint (boost::asio::ip::address_v6::any (), server_port);
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ TEST (socket, drop_policy)
|
|||
ASSERT_FALSE (ec);
|
||||
|
||||
// Accept connection, but don't read so the writer will drop.
|
||||
server_socket->on_connection ([&connections](std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
server_socket->on_connection ([&connections] (std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
connections.push_back (new_connection);
|
||||
return true;
|
||||
});
|
||||
|
|
@ -38,12 +38,12 @@ TEST (socket, drop_policy)
|
|||
nano::util::counted_completion write_completion (static_cast<unsigned> (total_message_count));
|
||||
|
||||
client->async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v6::loopback (), server_port),
|
||||
[&channel, total_message_count, node, &write_completion, &drop_policy, client](boost::system::error_code const & ec_a) mutable {
|
||||
[&channel, total_message_count, node, &write_completion, &drop_policy, client] (boost::system::error_code const & ec_a) mutable {
|
||||
for (int i = 0; i < total_message_count; i++)
|
||||
{
|
||||
std::vector<uint8_t> buff (1);
|
||||
channel.send_buffer (
|
||||
nano::shared_const_buffer (std::move (buff)), [&write_completion, client](boost::system::error_code const & ec, size_t size_a) mutable {
|
||||
nano::shared_const_buffer (std::move (buff)), [&write_completion, client] (boost::system::error_code const & ec, size_t size_a) mutable {
|
||||
client.reset ();
|
||||
write_completion.increment ();
|
||||
},
|
||||
|
|
@ -88,7 +88,7 @@ TEST (socket, concurrent_writes)
|
|||
|
||||
// We're expecting client_count*4 messages
|
||||
nano::util::counted_completion read_count_completion (total_message_count);
|
||||
std::function<void(std::shared_ptr<nano::socket> const &)> reader = [&read_count_completion, &total_message_count, &reader](std::shared_ptr<nano::socket> const & socket_a) {
|
||||
std::function<void (std::shared_ptr<nano::socket> const &)> reader = [&read_count_completion, &total_message_count, &reader] (std::shared_ptr<nano::socket> const & socket_a) {
|
||||
auto buff (std::make_shared<std::vector<uint8_t>> ());
|
||||
buff->resize (1);
|
||||
#ifndef _WIN32
|
||||
|
|
@ -100,7 +100,7 @@ TEST (socket, concurrent_writes)
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
socket_a->async_read (buff, 1, [&read_count_completion, &reader, &total_message_count, socket_a, buff](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_a->async_read (buff, 1, [&read_count_completion, &reader, &total_message_count, socket_a, buff] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
if (read_count_completion.increment () < total_message_count)
|
||||
|
|
@ -127,7 +127,7 @@ TEST (socket, concurrent_writes)
|
|||
std::vector<std::shared_ptr<nano::socket>> connections;
|
||||
|
||||
// On every new connection, start reading data
|
||||
server_socket->on_connection ([&connections, &reader](std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
server_socket->on_connection ([&connections, &reader] (std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
std::cerr << "on_connection: " << ec_a.message () << std::endl;
|
||||
|
|
@ -148,7 +148,7 @@ TEST (socket, concurrent_writes)
|
|||
auto client = std::make_shared<nano::socket> (*node, boost::none);
|
||||
clients.push_back (client);
|
||||
client->async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v4::loopback (), 25000),
|
||||
[&connection_count_completion](boost::system::error_code const & ec_a) {
|
||||
[&connection_count_completion] (boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
std::cerr << "async_connect: " << ec_a.message () << std::endl;
|
||||
|
|
@ -175,7 +175,7 @@ TEST (socket, concurrent_writes)
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
client_threads.emplace_back ([&client, &message_count]() {
|
||||
client_threads.emplace_back ([&client, &message_count] () {
|
||||
for (int i = 0; i < message_count; i++)
|
||||
{
|
||||
std::vector<uint8_t> buff;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ TEST (telemetry, basic)
|
|||
auto channel = node_client->network.find_channel (node_server->network.endpoint ());
|
||||
{
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
ASSERT_EQ (server_endpoint, response_a.endpoint);
|
||||
telemetry_data = response_a.telemetry_data;
|
||||
|
|
@ -258,7 +258,7 @@ TEST (telemetry, basic)
|
|||
// Call again straight away. It should use the cache
|
||||
{
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_EQ (telemetry_data, response_a.telemetry_data);
|
||||
ASSERT_FALSE (response_a.error);
|
||||
done = true;
|
||||
|
|
@ -271,7 +271,7 @@ TEST (telemetry, basic)
|
|||
std::this_thread::sleep_for (nano::telemetry_cache_cutoffs::dev);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_NE (telemetry_data, response_a.telemetry_data);
|
||||
ASSERT_FALSE (response_a.error);
|
||||
done = true;
|
||||
|
|
@ -303,7 +303,7 @@ TEST (telemetry, over_udp)
|
|||
|
||||
std::atomic<bool> done{ false };
|
||||
auto channel = node_client->network.find_channel (node_server->network.endpoint ());
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &node_server](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &node_server] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
nano::compare_default_telemetry_response_data (response_a.telemetry_data, node_server->network_params, node_server->config.bandwidth_limit, node_server->active.active_difficulty (), node_server->node_id);
|
||||
done = true;
|
||||
|
|
@ -330,7 +330,7 @@ TEST (telemetry, invalid_channel)
|
|||
auto node_server = system.nodes.back ();
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (nullptr, [&done](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (nullptr, [&done] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_TRUE (response_a.error);
|
||||
done = true;
|
||||
});
|
||||
|
|
@ -349,9 +349,9 @@ TEST (telemetry, blocking_request)
|
|||
|
||||
// Request telemetry metrics
|
||||
std::atomic<bool> done{ false };
|
||||
std::function<void()> call_system_poll;
|
||||
std::function<void ()> call_system_poll;
|
||||
std::promise<void> promise;
|
||||
call_system_poll = [&call_system_poll, &workers = node_client->workers, &done, &system, &promise]() {
|
||||
call_system_poll = [&call_system_poll, &workers = node_client->workers, &done, &system, &promise] () {
|
||||
if (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
|
|
@ -392,7 +392,7 @@ TEST (telemetry, disconnects)
|
|||
ASSERT_TRUE (channel);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_TRUE (response_a.error);
|
||||
done = true;
|
||||
});
|
||||
|
|
@ -414,7 +414,7 @@ TEST (telemetry, dos_tcp)
|
|||
|
||||
nano::telemetry_req message;
|
||||
auto channel = node_client->network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node_server->network.endpoint ()));
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ TEST (telemetry, dos_tcp)
|
|||
auto orig = std::chrono::steady_clock::now ();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
}
|
||||
|
|
@ -457,7 +457,7 @@ TEST (telemetry, dos_udp)
|
|||
|
||||
nano::telemetry_req message;
|
||||
auto channel (node_client->network.udp_channels.create (node_server->network.endpoint ()));
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ TEST (telemetry, dos_udp)
|
|||
auto orig = std::chrono::steady_clock::now ();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
}
|
||||
|
|
@ -501,7 +501,7 @@ TEST (telemetry, disable_metrics)
|
|||
ASSERT_TRUE (channel);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_TRUE (response_a.error);
|
||||
done = true;
|
||||
});
|
||||
|
|
@ -511,7 +511,7 @@ TEST (telemetry, disable_metrics)
|
|||
// It should still be able to receive metrics though
|
||||
done = false;
|
||||
auto channel1 = node_server->network.find_channel (node_client->network.endpoint ());
|
||||
node_server->telemetry->get_metrics_single_peer_async (channel1, [&done, node_client](nano::telemetry_data_response const & response_a) {
|
||||
node_server->telemetry->get_metrics_single_peer_async (channel1, [&done, node_client] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
nano::compare_default_telemetry_response_data (response_a.telemetry_data, node_client->network_params, node_client->config.bandwidth_limit, node_client->active.active_difficulty (), node_client->node_id);
|
||||
done = true;
|
||||
|
|
@ -536,7 +536,7 @@ TEST (telemetry, max_possible_size)
|
|||
wait_peer_connections (system);
|
||||
|
||||
auto channel = node_client->network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node_server->network.endpoint ()));
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
|
|
@ -596,11 +596,11 @@ TEST (telemetry, remove_peer_different_genesis_udp)
|
|||
std::atomic<bool> done0{ false };
|
||||
std::atomic<bool> done1{ false };
|
||||
|
||||
node0->telemetry->get_metrics_single_peer_async (channel1, [&done0](nano::telemetry_data_response const & response_a) {
|
||||
node0->telemetry->get_metrics_single_peer_async (channel1, [&done0] (nano::telemetry_data_response const & response_a) {
|
||||
done0 = true;
|
||||
});
|
||||
|
||||
node1->telemetry->get_metrics_single_peer_async (channel0, [&done1](nano::telemetry_data_response const & response_a) {
|
||||
node1->telemetry->get_metrics_single_peer_async (channel0, [&done1] (nano::telemetry_data_response const & response_a) {
|
||||
done1 = true;
|
||||
});
|
||||
|
||||
|
|
@ -635,7 +635,7 @@ TEST (telemetry, remove_peer_invalid_signature)
|
|||
node->network.process_message (telemetry_ack, channel);
|
||||
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::telemetry, nano::stat::detail::invalid_signature) > 0);
|
||||
ASSERT_NO_ERROR (system.poll_until_true (3s, [&node, address = channel->get_endpoint ().address ()]() -> bool {
|
||||
ASSERT_NO_ERROR (system.poll_until_true (3s, [&node, address = channel->get_endpoint ().address ()] () -> bool {
|
||||
nano::lock_guard<nano::mutex> guard (node->network.excluded_peers.mutex);
|
||||
return node->network.excluded_peers.peers.get<nano::peer_exclusion::tag_endpoint> ().count (address);
|
||||
}));
|
||||
|
|
@ -662,7 +662,7 @@ TEST (telemetry, maker_pruning)
|
|||
auto channel = node_client->network.find_channel (node_server->network.endpoint ());
|
||||
{
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
ASSERT_EQ (server_endpoint, response_a.endpoint);
|
||||
telemetry_data = response_a.telemetry_data;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ TEST (thread, thread_pool)
|
|||
{
|
||||
std::atomic<bool> passed_sleep{ false };
|
||||
|
||||
auto func = [&passed_sleep]() {
|
||||
auto func = [&passed_sleep] () {
|
||||
std::this_thread::sleep_for (std::chrono::seconds (1));
|
||||
passed_sleep = true;
|
||||
};
|
||||
|
|
@ -122,7 +122,7 @@ TEST (thread_pool_alarm, one)
|
|||
std::atomic<bool> done (false);
|
||||
nano::mutex mutex;
|
||||
nano::condition_variable condition;
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&] () {
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
done = true;
|
||||
|
|
@ -130,7 +130,7 @@ TEST (thread_pool_alarm, one)
|
|||
condition.notify_one ();
|
||||
});
|
||||
nano::unique_lock<nano::mutex> unique (mutex);
|
||||
condition.wait (unique, [&]() { return !!done; });
|
||||
condition.wait (unique, [&] () { return !!done; });
|
||||
}
|
||||
|
||||
TEST (thread_pool_alarm, many)
|
||||
|
|
@ -141,7 +141,7 @@ TEST (thread_pool_alarm, many)
|
|||
nano::condition_variable condition;
|
||||
for (auto i (0); i < 50; ++i)
|
||||
{
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&] () {
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
count += 1;
|
||||
|
|
@ -150,7 +150,7 @@ TEST (thread_pool_alarm, many)
|
|||
});
|
||||
}
|
||||
nano::unique_lock<nano::mutex> unique (mutex);
|
||||
condition.wait (unique, [&]() { return count == 50; });
|
||||
condition.wait (unique, [&] () { return count == 50; });
|
||||
}
|
||||
|
||||
TEST (thread_pool_alarm, top_execution)
|
||||
|
|
@ -160,12 +160,12 @@ TEST (thread_pool_alarm, top_execution)
|
|||
int value2 (0);
|
||||
nano::mutex mutex;
|
||||
std::promise<bool> promise;
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&] () {
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
value1 = 1;
|
||||
value2 = 1;
|
||||
});
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (1), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (1), [&] () {
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
value2 = 2;
|
||||
promise.set_value (false);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ TEST (vote_generator, cache)
|
|||
ASSERT_TIMELY (1s, !node.history.votes (epoch1->root (), epoch1->hash ()).empty ());
|
||||
auto votes (node.history.votes (epoch1->root (), epoch1->hash ()));
|
||||
ASSERT_FALSE (votes.empty ());
|
||||
ASSERT_TRUE (std::any_of (votes[0]->begin (), votes[0]->end (), [hash = epoch1->hash ()](nano::block_hash const & hash_a) { return hash_a == hash; }));
|
||||
ASSERT_TRUE (std::any_of (votes[0]->begin (), votes[0]->end (), [hash = epoch1->hash ()] (nano::block_hash const & hash_a) { return hash_a == hash; }));
|
||||
}
|
||||
|
||||
TEST (vote_generator, multiple_representatives)
|
||||
|
|
@ -97,7 +97,7 @@ TEST (vote_generator, multiple_representatives)
|
|||
auto votes (node.history.votes (send->root (), send->hash ()));
|
||||
for (auto const & account : { key1.pub, key2.pub, key3.pub, nano::dev_genesis_key.pub })
|
||||
{
|
||||
auto existing (std::find_if (votes.begin (), votes.end (), [&account](std::shared_ptr<nano::vote> const & vote_a) -> bool {
|
||||
auto existing (std::find_if (votes.begin (), votes.end (), [&account] (std::shared_ptr<nano::vote> const & vote_a) -> bool {
|
||||
return vote_a->account == account;
|
||||
}));
|
||||
ASSERT_NE (votes.end (), existing);
|
||||
|
|
@ -110,7 +110,7 @@ TEST (vote_generator, session)
|
|||
auto node (system.nodes[0]);
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::vote_generator_session generator_session (node->active.generator);
|
||||
boost::thread thread ([node, &generator_session]() {
|
||||
boost::thread thread ([node, &generator_session] () {
|
||||
nano::thread_role::set (nano::thread_role::name::request_loop);
|
||||
generator_session.add (nano::genesis_account, nano::genesis_hash);
|
||||
ASSERT_EQ (0, node->stats.count (nano::stat::type::vote, nano::stat::detail::vote_indeterminate));
|
||||
|
|
|
|||
|
|
@ -198,11 +198,11 @@ TEST (wallet, send_async)
|
|||
nano::system system (1);
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::keypair key2;
|
||||
std::thread thread ([&system]() {
|
||||
std::thread thread ([&system] () {
|
||||
ASSERT_TIMELY (10s, system.nodes[0]->balance (nano::dev_genesis_key.pub).is_zero ());
|
||||
});
|
||||
std::atomic<bool> success (false);
|
||||
system.wallet (0)->send_async (nano::dev_genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), [&success](std::shared_ptr<nano::block> const & block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
system.wallet (0)->send_async (nano::dev_genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), [&success] (std::shared_ptr<nano::block> const & block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
thread.join ();
|
||||
ASSERT_TIMELY (2s, success);
|
||||
}
|
||||
|
|
@ -846,7 +846,7 @@ TEST (wallet, password_race)
|
|||
nano::system system (1);
|
||||
nano::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
auto wallet = system.wallet (0);
|
||||
std::thread thread ([&wallet]() {
|
||||
std::thread thread ([&wallet] () {
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_write ());
|
||||
|
|
@ -884,21 +884,21 @@ TEST (wallet, password_race_corrupt_seed)
|
|||
std::vector<std::thread> threads;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
threads.emplace_back ([&wallet]() {
|
||||
threads.emplace_back ([&wallet] () {
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_write ());
|
||||
wallet->store.rekey (transaction, "0000");
|
||||
}
|
||||
});
|
||||
threads.emplace_back ([&wallet]() {
|
||||
threads.emplace_back ([&wallet] () {
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_write ());
|
||||
wallet->store.rekey (transaction, "1234");
|
||||
}
|
||||
});
|
||||
threads.emplace_back ([&wallet]() {
|
||||
threads.emplace_back ([&wallet] () {
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_read ());
|
||||
|
|
@ -1175,7 +1175,7 @@ TEST (wallet, foreach_representative_deadlock)
|
|||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
node.wallets.compute_reps ();
|
||||
ASSERT_EQ (1, node.wallets.reps ().voting);
|
||||
node.wallets.foreach_representative ([&node](nano::public_key const & pub, nano::raw_key const & prv) {
|
||||
node.wallets.foreach_representative ([&node] (nano::public_key const & pub, nano::raw_key const & prv) {
|
||||
if (node.wallets.mutex.try_lock ())
|
||||
{
|
||||
node.wallets.mutex.unlock ();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ TEST (websocket, subscription_edge)
|
|||
|
||||
ASSERT_EQ (0, node1->websocket_server->subscriber_count (nano::websocket::topic::confirmation));
|
||||
|
||||
auto task = ([config, &node1]() {
|
||||
auto task = ([config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -65,7 +65,7 @@ TEST (websocket, active_difficulty)
|
|||
ASSERT_EQ (0, node1->websocket_server->subscriber_count (nano::websocket::topic::active_difficulty));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "active_difficulty", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -129,7 +129,7 @@ TEST (websocket, confirmation)
|
|||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
std::atomic<bool> unsubscribed{ false };
|
||||
auto task = ([&ack_ready, &unsubscribed, config, &node1]() {
|
||||
auto task = ([&ack_ready, &unsubscribed, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -186,7 +186,7 @@ TEST (websocket, stopped_election)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "stopped_election", "ack": "true"})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -229,7 +229,7 @@ TEST (websocket, confirmation_options)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task1 = ([&ack_ready, config, &node1]() {
|
||||
auto task1 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "accounts": ["xrb_invalid"]}})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -258,7 +258,7 @@ TEST (websocket, confirmation_options)
|
|||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
ack_ready = false;
|
||||
auto task2 = ([&ack_ready, config, &node1]() {
|
||||
auto task2 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "all_local_accounts": "true", "include_election_info": "true"}})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -309,7 +309,7 @@ TEST (websocket, confirmation_options)
|
|||
}
|
||||
|
||||
ack_ready = false;
|
||||
auto task3 = ([&ack_ready, config, &node1]() {
|
||||
auto task3 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "all_local_accounts": "true"}})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -343,7 +343,7 @@ TEST (websocket, confirmation_options_votes)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task1 = ([&ack_ready, config, &node1]() {
|
||||
auto task1 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "include_election_info_with_votes": "true", "include_block": "false"}})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -422,7 +422,7 @@ TEST (websocket, confirmation_options_update)
|
|||
|
||||
std::atomic<bool> added{ false };
|
||||
std::atomic<bool> deleted{ false };
|
||||
auto task = ([&added, &deleted, config, &node1]() {
|
||||
auto task = ([&added, &deleted, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
// Subscribe initially with empty options, everything will be filtered
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {}})json");
|
||||
|
|
@ -477,7 +477,7 @@ TEST (websocket, vote)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "vote", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -517,7 +517,7 @@ TEST (websocket, vote_options_type)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "vote", "ack": true, "options": {"include_replays": "true", "include_indeterminate": "false"}})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -559,7 +559,7 @@ TEST (websocket, vote_options_representatives)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task1 = ([&ack_ready, config, &node1]() {
|
||||
auto task1 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
std::string message = boost::str (boost::format (R"json({"action": "subscribe", "topic": "vote", "ack": "true", "options": {"representatives": ["%1%"]}})json") % nano::dev_genesis_key.pub.to_account ());
|
||||
client.send_message (message);
|
||||
|
|
@ -583,7 +583,7 @@ TEST (websocket, vote_options_representatives)
|
|||
auto balance = nano::genesis_amount;
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
auto send_amount = node1->online_reps.delta () + 1;
|
||||
auto confirm_block = [&]() {
|
||||
auto confirm_block = [&] () {
|
||||
nano::block_hash previous (node1->latest (nano::dev_genesis_key.pub));
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::state_block> (nano::dev_genesis_key.pub, previous, nano::dev_genesis_key.pub, balance, key.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *system.work.generate (previous)));
|
||||
|
|
@ -594,7 +594,7 @@ TEST (websocket, vote_options_representatives)
|
|||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
ack_ready = false;
|
||||
auto task2 = ([&ack_ready, config, &node1]() {
|
||||
auto task2 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "vote", "ack": "true", "options": {"representatives": ["xrb_invalid"]}})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -628,7 +628,7 @@ TEST (websocket, work)
|
|||
|
||||
// Subscribe to work and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "work", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -698,7 +698,7 @@ TEST (websocket, bootstrap)
|
|||
|
||||
// Subscribe to bootstrap and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "bootstrap", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -747,7 +747,7 @@ TEST (websocket, bootstrap_exited)
|
|||
// Start bootstrap, exit after subscription
|
||||
std::atomic<bool> bootstrap_started{ false };
|
||||
nano::util::counted_completion subscribed_completion (1);
|
||||
std::thread bootstrap_thread ([node1, &system, &bootstrap_started, &subscribed_completion]() {
|
||||
std::thread bootstrap_thread ([node1, &system, &bootstrap_started, &subscribed_completion] () {
|
||||
std::shared_ptr<nano::bootstrap_attempt> attempt;
|
||||
while (attempt == nullptr)
|
||||
{
|
||||
|
|
@ -765,7 +765,7 @@ TEST (websocket, bootstrap_exited)
|
|||
|
||||
// Subscribe to bootstrap and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "bootstrap", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -809,7 +809,7 @@ TEST (websocket, ws_keepalive)
|
|||
config.websocket_config.port = nano::get_available_port ();
|
||||
auto node1 (system.add_node (config));
|
||||
|
||||
auto task = ([config]() {
|
||||
auto task = ([config] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "ping"})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -838,7 +838,7 @@ TEST (websocket, telemetry)
|
|||
wait_peer_connections (system);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
auto task = ([config = node1->config, &node1, &done]() {
|
||||
auto task = ([config = node1->config, &node1, &done] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "telemetry", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
|
@ -851,7 +851,7 @@ TEST (websocket, telemetry)
|
|||
|
||||
ASSERT_TIMELY (10s, done);
|
||||
|
||||
node1->telemetry->get_metrics_single_peer_async (node1->network.find_channel (node2->network.endpoint ()), [](auto const & response_a) {
|
||||
node1->telemetry->get_metrics_single_peer_async (node1->network.find_channel (node2->network.endpoint ()), [] (auto const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
});
|
||||
|
||||
|
|
@ -888,7 +888,7 @@ TEST (websocket, new_unconfirmed_block)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, node1]() {
|
||||
auto task = ([&ack_ready, config, node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "new_unconfirmed_block", "ack": "true"})json");
|
||||
client.await_ack ();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ TEST (work, cancel)
|
|||
{
|
||||
nano::root key (1);
|
||||
pool.generate (
|
||||
nano::work_version::work_1, key, nano::network_constants ().publish_thresholds.base, [&done](boost::optional<uint64_t> work_a) {
|
||||
nano::work_version::work_1, key, nano::network_constants ().publish_thresholds.base, [&done] (boost::optional<uint64_t> work_a) {
|
||||
done = !work_a;
|
||||
});
|
||||
pool.cancel (key);
|
||||
|
|
@ -69,12 +69,12 @@ TEST (work, cancel_many)
|
|||
nano::root key5 (3);
|
||||
nano::root key6 (1);
|
||||
nano::network_constants constants;
|
||||
pool.generate (nano::work_version::work_1, key1, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key2, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key3, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key4, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key5, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key6, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key1, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key2, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key3, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key4, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key5, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key6, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.cancel (key1);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ TEST (work, opencl)
|
|||
if (opencl != nullptr)
|
||||
{
|
||||
// 0 threads, should add 1 for managing OpenCL
|
||||
nano::work_pool pool (0, std::chrono::nanoseconds (0), [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
nano::work_pool pool (0, std::chrono::nanoseconds (0), [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a);
|
||||
});
|
||||
ASSERT_NE (nullptr, pool.opencl);
|
||||
|
|
@ -159,7 +159,7 @@ TEST (work, difficulty)
|
|||
|
||||
TEST (work, eco_pow)
|
||||
{
|
||||
auto work_func = [](std::promise<std::chrono::nanoseconds> & promise, std::chrono::nanoseconds interval) {
|
||||
auto work_func = [] (std::promise<std::chrono::nanoseconds> & promise, std::chrono::nanoseconds interval) {
|
||||
nano::work_pool pool (1, interval);
|
||||
constexpr auto num_iterations = 5;
|
||||
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ TEST (work_watcher, confirm_while_generating)
|
|||
ASSERT_TIMELY (5s, 0 != node.work.size ());
|
||||
// Attach a callback to work cancellations
|
||||
std::atomic<bool> notified{ false };
|
||||
node.observers.work_cancel.add ([¬ified, &block1](nano::root const & root_a) {
|
||||
node.observers.work_cancel.add ([¬ified, &block1] (nano::root const & root_a) {
|
||||
EXPECT_EQ (root_a, block1->root ());
|
||||
notified = true;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ nano::ipc::flatbuffer_producer::flatbuffer_producer ()
|
|||
}
|
||||
|
||||
nano::ipc::flatbuffer_producer::flatbuffer_producer (std::shared_ptr<flatbuffers::FlatBufferBuilder> const & builder_a) :
|
||||
fbb (builder_a)
|
||||
fbb (builder_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace
|
|||
void read_message_loop (std::shared_ptr<nano::ipc::ipc_client> const & connection)
|
||||
{
|
||||
auto buffer (std::make_shared<std::vector<uint8_t>> ());
|
||||
connection->async_read_message (buffer, std::chrono::seconds::max (), [buffer, connection](nano::error error_a, size_t size_a) {
|
||||
connection->async_read_message (buffer, std::chrono::seconds::max (), [buffer, connection] (nano::error error_a, size_t size_a) {
|
||||
if (!error_a)
|
||||
{
|
||||
auto verifier (flatbuffers::Verifier (buffer->data (), buffer->size ()));
|
||||
|
|
@ -57,11 +57,11 @@ int main (int argc, char * const * argv)
|
|||
// be improved later to handle various options, including port and address.
|
||||
std::string ipc_address = "::1";
|
||||
uint16_t ipc_port = 7077;
|
||||
connection->async_connect (ipc_address, ipc_port, [connection](nano::error err) {
|
||||
connection->async_connect (ipc_address, ipc_port, [connection] (nano::error err) {
|
||||
if (!err)
|
||||
{
|
||||
nanoapi::TopicConfirmationT conf;
|
||||
connection->async_write (nano::ipc::shared_buffer_from (conf), [connection](nano::error err, size_t size) {
|
||||
connection->async_write (nano::ipc::shared_buffer_from (conf), [connection] (nano::error err, size_t size) {
|
||||
if (!err)
|
||||
{
|
||||
std::cout << "Awaiting confirmations..." << std::endl;
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
#include <nano/lib/asio.hpp>
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (const std::vector<uint8_t> & data) :
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data)),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data)),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (std::vector<uint8_t> && data) :
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (std::move (data))),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (std::move (data))),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (uint8_t data) :
|
||||
shared_const_buffer (std::vector<uint8_t>{ data })
|
||||
shared_const_buffer (std::vector<uint8_t>{ data })
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (std::string const & data) :
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data.begin (), data.end ())),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data.begin (), data.end ())),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (std::shared_ptr<std::vector<uint8_t>> const & data) :
|
||||
m_data (data),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (data),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ private:
|
|||
static_assert (boost::asio::is_const_buffer_sequence<shared_const_buffer>::value, "Not ConstBufferSequence compliant");
|
||||
|
||||
template <typename AsyncWriteStream, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void(boost::system::error_code, std::size_t))
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void (boost::system::error_code, std::size_t))
|
||||
async_write (AsyncWriteStream & s, nano::shared_const_buffer const & buffer, WriteHandler && handler)
|
||||
{
|
||||
return boost::asio::async_write (s, buffer, std::move (handler));
|
||||
|
|
@ -41,7 +41,7 @@ async_write (AsyncWriteStream & s, nano::shared_const_buffer const & buffer, Wri
|
|||
* @warning The buffers must be captured in the handler to ensure their lifetimes are properly extended.
|
||||
*/
|
||||
template <typename AsyncWriteStream, typename BufferType, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void(boost::system::error_code, std::size_t))
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void (boost::system::error_code, std::size_t))
|
||||
unsafe_async_write (AsyncWriteStream & s, BufferType && buffer, WriteHandler && handler)
|
||||
{
|
||||
return boost::asio::async_write (s, buffer, std::move (handler));
|
||||
|
|
|
|||
|
|
@ -221,9 +221,9 @@ void nano::send_block::block_work_set (uint64_t work_a)
|
|||
}
|
||||
|
||||
nano::send_hashables::send_hashables (nano::block_hash const & previous_a, nano::account const & destination_a, nano::amount const & balance_a) :
|
||||
previous (previous_a),
|
||||
destination (destination_a),
|
||||
balance (balance_a)
|
||||
previous (previous_a),
|
||||
destination (destination_a),
|
||||
balance (balance_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -364,14 +364,14 @@ bool nano::send_block::deserialize_json (boost::property_tree::ptree const & tre
|
|||
}
|
||||
|
||||
nano::send_block::send_block (nano::block_hash const & previous_a, nano::account const & destination_a, nano::amount const & balance_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (previous_a, destination_a, balance_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (previous_a, destination_a, balance_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::send_block::send_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -388,7 +388,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::send_block::send_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -474,9 +474,9 @@ void nano::send_block::signature_set (nano::signature const & signature_a)
|
|||
}
|
||||
|
||||
nano::open_hashables::open_hashables (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a) :
|
||||
source (source_a),
|
||||
representative (representative_a),
|
||||
account (account_a)
|
||||
source (source_a),
|
||||
representative (representative_a),
|
||||
account (account_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -525,22 +525,22 @@ void nano::open_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::open_block::open_block (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (source_a, representative_a, account_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (source_a, representative_a, account_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
debug_assert (!representative_a.is_zero ());
|
||||
}
|
||||
|
||||
nano::open_block::open_block (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a, std::nullptr_t) :
|
||||
hashables (source_a, representative_a, account_a),
|
||||
work (0)
|
||||
hashables (source_a, representative_a, account_a),
|
||||
work (0)
|
||||
{
|
||||
signature.clear ();
|
||||
}
|
||||
|
||||
nano::open_block::open_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -557,7 +557,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::open_block::open_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -745,8 +745,8 @@ void nano::open_block::signature_set (nano::signature const & signature_a)
|
|||
}
|
||||
|
||||
nano::change_hashables::change_hashables (nano::block_hash const & previous_a, nano::account const & representative_a) :
|
||||
previous (previous_a),
|
||||
representative (representative_a)
|
||||
previous (previous_a),
|
||||
representative (representative_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -788,14 +788,14 @@ void nano::change_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::change_block::change_block (nano::block_hash const & previous_a, nano::account const & representative_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (previous_a, representative_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (previous_a, representative_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::change_block::change_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -812,7 +812,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::change_block::change_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -994,11 +994,11 @@ void nano::change_block::signature_set (nano::signature const & signature_a)
|
|||
}
|
||||
|
||||
nano::state_hashables::state_hashables (nano::account const & account_a, nano::block_hash const & previous_a, nano::account const & representative_a, nano::amount const & balance_a, nano::link const & link_a) :
|
||||
account (account_a),
|
||||
previous (previous_a),
|
||||
representative (representative_a),
|
||||
balance (balance_a),
|
||||
link (link_a)
|
||||
account (account_a),
|
||||
previous (previous_a),
|
||||
representative (representative_a),
|
||||
balance (balance_a),
|
||||
link (link_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1061,14 +1061,14 @@ void nano::state_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::state_block::state_block (nano::account const & account_a, nano::block_hash const & previous_a, nano::account const & representative_a, nano::amount const & balance_a, nano::link const & link_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (account_a, previous_a, representative_a, balance_a, link_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (account_a, previous_a, representative_a, balance_a, link_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::state_block::state_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1086,7 +1086,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::state_block::state_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1506,14 +1506,14 @@ bool nano::receive_block::deserialize_json (boost::property_tree::ptree const &
|
|||
}
|
||||
|
||||
nano::receive_block::receive_block (nano::block_hash const & previous_a, nano::block_hash const & source_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (previous_a, source_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (previous_a, source_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::receive_block::receive_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1530,7 +1530,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::receive_block::receive_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1620,8 +1620,8 @@ nano::block_type nano::receive_block::type () const
|
|||
}
|
||||
|
||||
nano::receive_hashables::receive_hashables (nano::block_hash const & previous_a, nano::block_hash const & source_a) :
|
||||
previous (previous_a),
|
||||
source (source_a)
|
||||
previous (previous_a),
|
||||
source (source_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1663,7 +1663,7 @@ void nano::receive_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::block_details::block_details (nano::epoch const epoch_a, bool const is_send_a, bool const is_receive_a, bool const is_epoch_a) :
|
||||
epoch (epoch_a), is_send (is_send_a), is_receive (is_receive_a), is_epoch (is_epoch_a)
|
||||
epoch (epoch_a), is_send (is_send_a), is_receive (is_receive_a), is_epoch (is_epoch_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1735,24 +1735,24 @@ std::string nano::state_subtype (nano::block_details const details_a)
|
|||
}
|
||||
|
||||
nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, uint64_t const timestamp_a, nano::block_details const & details_a, nano::epoch const source_epoch_a) :
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (details_a),
|
||||
source_epoch (source_epoch_a)
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (details_a),
|
||||
source_epoch (source_epoch_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, uint64_t const timestamp_a, nano::epoch const epoch_a, bool const is_send, bool const is_receive, bool const is_epoch, nano::epoch const source_epoch_a) :
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (epoch_a, is_send, is_receive, is_epoch),
|
||||
source_epoch (source_epoch_a)
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (epoch_a, is_send, is_receive, is_epoch),
|
||||
source_epoch (source_epoch_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ nano::link const & nano::epochs::link (nano::epoch epoch_a) const
|
|||
|
||||
bool nano::epochs::is_epoch_link (nano::link const & link_a) const
|
||||
{
|
||||
return std::any_of (epochs_m.begin (), epochs_m.end (), [&link_a](auto const & item_a) { return item_a.second.link == link_a; });
|
||||
return std::any_of (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; });
|
||||
}
|
||||
|
||||
nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const
|
||||
|
|
@ -18,7 +18,7 @@ nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const
|
|||
|
||||
nano::epoch nano::epochs::epoch (nano::link const & link_a) const
|
||||
{
|
||||
auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a](auto const & item_a) { return item_a.second.link == link_a; }));
|
||||
auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; }));
|
||||
debug_assert (existing != epochs_m.end ());
|
||||
return existing->first;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ namespace std
|
|||
{
|
||||
template <>
|
||||
struct is_error_code_enum<boost::system::errc::errc_t>
|
||||
: public std::true_type
|
||||
: public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ public:
|
|||
{
|
||||
// Convert variadic arguments to std::error_code
|
||||
auto codes = { std::error_code (err)... };
|
||||
if (std::any_of (codes.begin (), codes.end (), [this, &codes](auto & code_a) { return code == code_a; }))
|
||||
if (std::any_of (codes.begin (), codes.end (), [this, &codes] (auto & code_a) { return code == code_a; }))
|
||||
{
|
||||
code.clear ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <nano/lib/utility.hpp>
|
||||
|
||||
nano::ipc::socket_base::socket_base (boost::asio::io_context & io_ctx_a) :
|
||||
io_timer (io_ctx_a)
|
||||
io_timer (io_ctx_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ void nano::ipc::socket_base::timer_start (std::chrono::seconds timeout_a)
|
|||
if (timeout_a < std::chrono::seconds::max ())
|
||||
{
|
||||
io_timer.expires_from_now (boost::posix_time::seconds (static_cast<long> (timeout_a.count ())));
|
||||
io_timer.async_wait ([this](const boost::system::error_code & ec) {
|
||||
io_timer.async_wait ([this] (const boost::system::error_code & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
this->timer_expired ();
|
||||
|
|
@ -33,7 +33,7 @@ void nano::ipc::socket_base::timer_cancel ()
|
|||
}
|
||||
|
||||
nano::ipc::dsock_file_remover::dsock_file_remover (std::string const & file_a) :
|
||||
filename (file_a)
|
||||
filename (file_a)
|
||||
{
|
||||
std::remove (filename.c_str ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ namespace
|
|||
class channel
|
||||
{
|
||||
public:
|
||||
virtual void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_write (nano::shared_const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_write (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
|
||||
/**
|
||||
* Read a length-prefixed message asynchronously using the given timeout. This is suitable for full duplex scenarios where it may
|
||||
|
|
@ -30,7 +30,7 @@ public:
|
|||
* @param timeout_a How long to await message data. In some scenarios, such as waiting for data on subscriptions, specifying std::chrono::seconds::max() makes sense.
|
||||
* @param callback_a If called without errors, the payload buffer is successfully populated
|
||||
*/
|
||||
virtual void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
};
|
||||
|
||||
/* Boost v1.70 introduced breaking changes; the conditional compilation allows 1.6x to be supported as well. */
|
||||
|
|
@ -50,11 +50,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void async_resolve (std::string const & host_a, uint16_t port_a, std::function<void(boost::system::error_code const &, boost::asio::ip::tcp::endpoint)> callback_a)
|
||||
void async_resolve (std::string const & host_a, uint16_t port_a, std::function<void (boost::system::error_code const &, boost::asio::ip::tcp::endpoint)> callback_a)
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (io_timeout);
|
||||
resolver.async_resolve (boost::asio::ip::tcp::resolver::query (host_a, std::to_string (port_a)), [this_l, callback_a](boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator_a) {
|
||||
resolver.async_resolve (boost::asio::ip::tcp::resolver::query (host_a, std::to_string (port_a)), [this_l, callback_a] (boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator_a) {
|
||||
this_l->timer_cancel ();
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
if (!ec && endpoint_iterator_a != end)
|
||||
|
|
@ -69,31 +69,31 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
void async_connect (std::function<void(boost::system::error_code const &)> callback_a)
|
||||
void async_connect (std::function<void (boost::system::error_code const &)> callback_a)
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (io_timeout);
|
||||
socket.async_connect (endpoint, boost::asio::bind_executor (strand, [this_l, callback_a](boost::system::error_code const & ec) {
|
||||
socket.async_connect (endpoint, boost::asio::bind_executor (strand, [this_l, callback_a] (boost::system::error_code const & ec) {
|
||||
this_l->timer_cancel ();
|
||||
callback_a (ec);
|
||||
}));
|
||||
}
|
||||
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) override
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (io_timeout);
|
||||
buffer_a->resize (size_a);
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), size_a), boost::asio::bind_executor (this_l->strand, [this_l, buffer_a, callback_a](boost::system::error_code const & ec, size_t size_a) {
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), size_a), boost::asio::bind_executor (this_l->strand, [this_l, buffer_a, callback_a] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
callback_a (ec, size_a);
|
||||
}));
|
||||
}
|
||||
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) override
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffer_a, callback_a, this_l]() {
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffer_a, callback_a, this_l] () {
|
||||
bool write_in_progress = !this_l->send_queue.empty ();
|
||||
auto queue_size = this_l->send_queue.size ();
|
||||
if (queue_size < this_l->queue_size_max)
|
||||
|
|
@ -114,7 +114,7 @@ public:
|
|||
this_l->timer_start (io_timeout);
|
||||
nano::async_write (socket, msg.buffer,
|
||||
boost::asio::bind_executor (strand,
|
||||
[msg, this_l](boost::system::error_code ec, std::size_t size_a) {
|
||||
[msg, this_l] (boost::system::error_code ec, std::size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
|
||||
if (msg.callback)
|
||||
|
|
@ -130,13 +130,13 @@ public:
|
|||
}));
|
||||
}
|
||||
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) override
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (timeout_a);
|
||||
buffer_a->resize (4);
|
||||
// Read 32 bit big-endian length
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), 4), boost::asio::bind_executor (this_l->strand, [this_l, timeout_a, buffer_a, callback_a](boost::system::error_code const & ec, size_t size_a) {
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), 4), boost::asio::bind_executor (this_l->strand, [this_l, timeout_a, buffer_a, callback_a] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
if (!ec)
|
||||
{
|
||||
|
|
@ -144,7 +144,7 @@ public:
|
|||
buffer_a->resize (payload_size_l);
|
||||
// Read payload
|
||||
this_l->timer_start (timeout_a);
|
||||
this_l->async_read (buffer_a, payload_size_l, [this_l, buffer_a, callback_a](boost::system::error_code const & ec_a, size_t size_a) {
|
||||
this_l->async_read (buffer_a, payload_size_l, [this_l, buffer_a, callback_a] (boost::system::error_code const & ec_a, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
callback_a (ec_a, size_a);
|
||||
});
|
||||
|
|
@ -160,7 +160,7 @@ public:
|
|||
void close () override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [this_l]() {
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [this_l] () {
|
||||
this_l->socket.shutdown (boost::asio::ip::tcp::socket::shutdown_both);
|
||||
this_l->socket.close ();
|
||||
}));
|
||||
|
|
@ -171,12 +171,12 @@ private:
|
|||
class queue_item
|
||||
{
|
||||
public:
|
||||
queue_item (nano::shared_const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) :
|
||||
queue_item (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) :
|
||||
buffer (buffer_a), callback (callback_a)
|
||||
{
|
||||
}
|
||||
nano::shared_const_buffer buffer;
|
||||
std::function<void(boost::system::error_code const &, size_t)> callback;
|
||||
std::function<void (boost::system::error_code const &, size_t)> callback;
|
||||
};
|
||||
size_t const queue_size_max = 64 * 1024;
|
||||
/** The send queue is protected by always being accessed through the strand */
|
||||
|
|
@ -201,14 +201,14 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void connect (std::string const & host_a, uint16_t port_a, std::function<void(nano::error)> callback_a)
|
||||
void connect (std::string const & host_a, uint16_t port_a, std::function<void (nano::error)> callback_a)
|
||||
{
|
||||
tcp_client = std::make_shared<socket_client<socket_type, boost::asio::ip::tcp::endpoint>> (io_ctx, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v6 (), port_a));
|
||||
|
||||
tcp_client->async_resolve (host_a, port_a, [this, callback_a](boost::system::error_code const & ec_resolve_a, boost::asio::ip::tcp::endpoint endpoint_a) {
|
||||
tcp_client->async_resolve (host_a, port_a, [this, callback_a] (boost::system::error_code const & ec_resolve_a, boost::asio::ip::tcp::endpoint endpoint_a) {
|
||||
if (!ec_resolve_a)
|
||||
{
|
||||
this->tcp_client->async_connect ([callback_a](const boost::system::error_code & ec_connect_a) {
|
||||
this->tcp_client->async_connect ([callback_a] (const boost::system::error_code & ec_connect_a) {
|
||||
callback_a (nano::error (ec_connect_a));
|
||||
});
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ private:
|
|||
}
|
||||
|
||||
nano::ipc::ipc_client::ipc_client (boost::asio::io_context & io_ctx_a) :
|
||||
io_ctx (io_ctx_a)
|
||||
io_ctx (io_ctx_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ nano::error nano::ipc::ipc_client::connect (std::string const & path_a)
|
|||
return boost::polymorphic_downcast<client_impl *> (impl.get ())->connect (path_a);
|
||||
}
|
||||
|
||||
void nano::ipc::ipc_client::async_connect (std::string const & host_a, uint16_t port_a, std::function<void(nano::error)> callback_a)
|
||||
void nano::ipc::ipc_client::async_connect (std::string const & host_a, uint16_t port_a, std::function<void (nano::error)> callback_a)
|
||||
{
|
||||
impl = std::make_unique<client_impl> (io_ctx);
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
|
|
@ -269,33 +269,33 @@ void nano::ipc::ipc_client::async_connect (std::string const & host_a, uint16_t
|
|||
nano::error nano::ipc::ipc_client::connect (std::string const & host, uint16_t port)
|
||||
{
|
||||
std::promise<nano::error> result_l;
|
||||
async_connect (host, port, [&result_l](nano::error err_a) {
|
||||
async_connect (host, port, [&result_l] (nano::error err_a) {
|
||||
result_l.set_value (err_a);
|
||||
});
|
||||
return result_l.get_future ().get ();
|
||||
}
|
||||
|
||||
void nano::ipc::ipc_client::async_write (nano::shared_const_buffer const & buffer_a, std::function<void(nano::error, size_t)> callback_a)
|
||||
void nano::ipc::ipc_client::async_write (nano::shared_const_buffer const & buffer_a, std::function<void (nano::error, size_t)> callback_a)
|
||||
{
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
client->get_channel ().async_write (buffer_a, [callback_a](const boost::system::error_code & ec_a, size_t bytes_written_a) {
|
||||
client->get_channel ().async_write (buffer_a, [callback_a] (const boost::system::error_code & ec_a, size_t bytes_written_a) {
|
||||
callback_a (nano::error (ec_a), bytes_written_a);
|
||||
});
|
||||
}
|
||||
|
||||
void nano::ipc::ipc_client::async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(nano::error, size_t)> callback_a)
|
||||
void nano::ipc::ipc_client::async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (nano::error, size_t)> callback_a)
|
||||
{
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
client->get_channel ().async_read (buffer_a, size_a, [callback_a, buffer_a](const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
client->get_channel ().async_read (buffer_a, size_a, [callback_a, buffer_a] (const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
callback_a (nano::error (ec_a), bytes_read_a);
|
||||
});
|
||||
}
|
||||
|
||||
/** Read a length-prefixed message asynchronously. Received length must be a big endian 32-bit unsigned integer. */
|
||||
void nano::ipc::ipc_client::async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(nano::error, size_t)> callback_a)
|
||||
void nano::ipc::ipc_client::async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (nano::error, size_t)> callback_a)
|
||||
{
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
client->get_channel ().async_read_message (buffer_a, timeout_a, [callback_a, buffer_a](const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
client->get_channel ().async_read_message (buffer_a, timeout_a, [callback_a, buffer_a] (const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
callback_a (nano::error (ec_a), bytes_read_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -342,12 +342,12 @@ std::string nano::ipc::request (nano::ipc::payload_encoding encoding_a, nano::ip
|
|||
auto res (std::make_shared<std::vector<uint8_t>> ());
|
||||
|
||||
std::promise<std::string> result_l;
|
||||
ipc_client.async_write (req, [&ipc_client, &res, &result_l](nano::error err_a, size_t size_a) {
|
||||
ipc_client.async_write (req, [&ipc_client, &res, &result_l] (nano::error err_a, size_t size_a) {
|
||||
// Read length
|
||||
ipc_client.async_read (res, sizeof (uint32_t), [&ipc_client, &res, &result_l](nano::error err_read_a, size_t size_read_a) {
|
||||
ipc_client.async_read (res, sizeof (uint32_t), [&ipc_client, &res, &result_l] (nano::error err_read_a, size_t size_read_a) {
|
||||
uint32_t payload_size_l = boost::endian::big_to_native (*reinterpret_cast<uint32_t *> (res->data ()));
|
||||
// Read json payload
|
||||
ipc_client.async_read (res, payload_size_l, [&res, &result_l](nano::error err_read_a, size_t size_read_a) {
|
||||
ipc_client.async_read (res, payload_size_l, [&res, &result_l] (nano::error err_read_a, size_t size_read_a) {
|
||||
result_l.set_value (std::string (res->begin (), res->end ()));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ namespace ipc
|
|||
nano::error connect (std::string const & host, uint16_t port);
|
||||
|
||||
/** Connect to a tcp socket asynchronously */
|
||||
void async_connect (std::string const & host, uint16_t port, std::function<void(nano::error)> callback);
|
||||
void async_connect (std::string const & host, uint16_t port, std::function<void (nano::error)> callback);
|
||||
|
||||
/** Write buffer asynchronously */
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void(nano::error, size_t)> callback_a);
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void (nano::error, size_t)> callback_a);
|
||||
|
||||
/** Read \p size_a bytes asynchronously */
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(nano::error, size_t)> callback_a);
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (nano::error, size_t)> callback_a);
|
||||
|
||||
/**
|
||||
* Read a length-prefixed message asynchronously using the given timeout. This is suitable for full duplex scenarios where it may
|
||||
|
|
@ -54,7 +54,7 @@ namespace ipc
|
|||
* @param timeout_a How long to await message data. In some scenarios, such as waiting for data on subscriptions, specifying std::chrono::seconds::max() makes sense.
|
||||
* @param callback_a If called without errors, the payload buffer is successfully populated
|
||||
*/
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(nano::error, size_t)> callback_a);
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (nano::error, size_t)> callback_a);
|
||||
|
||||
private:
|
||||
boost::asio::io_context & io_ctx;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
inline void json_error_response (std::function<void(std::string const &)> response_a, std::string const & message_a)
|
||||
inline void json_error_response (std::function<void (std::string const &)> response_a, std::string const & message_a)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("error", message_a);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
#include <cstddef>
|
||||
|
||||
nano::jsonconfig::jsonconfig () :
|
||||
tree (tree_default)
|
||||
tree (tree_default)
|
||||
{
|
||||
error = std::make_shared<nano::error> ();
|
||||
}
|
||||
|
||||
nano::jsonconfig::jsonconfig (boost::property_tree::ptree & tree_a, std::shared_ptr<nano::error> const & error_a) :
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
|
@ -192,7 +192,7 @@ nano::jsonconfig & nano::jsonconfig::get_config (bool optional, std::string key,
|
|||
|
||||
nano::jsonconfig & nano::jsonconfig::get_config (bool optional, std::string key, bool & target, bool default_value)
|
||||
{
|
||||
auto bool_conv = [this, &target, &key, optional](std::string val) {
|
||||
auto bool_conv = [this, &target, &key, optional] (std::string val) {
|
||||
if (val == "true")
|
||||
{
|
||||
target = true;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public:
|
|||
|
||||
/** Iterate array entries */
|
||||
template <typename T>
|
||||
jsonconfig & array_entries (std::function<void(T)> callback)
|
||||
jsonconfig & array_entries (std::function<void (T)> callback)
|
||||
{
|
||||
for (auto & entry : tree)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void output_if_blocked_long_enough (nano::timer<std::chrono::milliseconds> & tim
|
|||
#endif
|
||||
|
||||
lock_guard<nano::mutex>::lock_guard (nano::mutex & mutex) :
|
||||
mut (mutex)
|
||||
mut (mutex)
|
||||
{
|
||||
timer.start ();
|
||||
|
||||
|
|
@ -77,14 +77,14 @@ lock_guard<nano::mutex>::~lock_guard () noexcept
|
|||
|
||||
template <typename Mutex, typename U>
|
||||
unique_lock<Mutex, U>::unique_lock (Mutex & mutex) :
|
||||
mut (std::addressof (mutex))
|
||||
mut (std::addressof (mutex))
|
||||
{
|
||||
lock_impl ();
|
||||
}
|
||||
|
||||
template <typename Mutex, typename U>
|
||||
unique_lock<Mutex, U>::unique_lock (Mutex & mutex, std::defer_lock_t) noexcept :
|
||||
mut (std::addressof (mutex))
|
||||
mut (std::addressof (mutex))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ void nano::set_use_memory_pools (bool use_memory_pools_a)
|
|||
#endif
|
||||
}
|
||||
|
||||
nano::cleanup_guard::cleanup_guard (std::vector<std::function<void()>> const & cleanup_funcs_a) :
|
||||
cleanup_funcs (cleanup_funcs_a)
|
||||
nano::cleanup_guard::cleanup_guard (std::vector<std::function<void ()>> const & cleanup_funcs_a) :
|
||||
cleanup_funcs (cleanup_funcs_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ bool purge_shared_ptr_singleton_pool_memory ()
|
|||
class cleanup_guard final
|
||||
{
|
||||
public:
|
||||
cleanup_guard (std::vector<std::function<void()>> const & cleanup_funcs_a);
|
||||
cleanup_guard (std::vector<std::function<void ()>> const & cleanup_funcs_a);
|
||||
~cleanup_guard ();
|
||||
|
||||
private:
|
||||
std::vector<std::function<void()>> cleanup_funcs;
|
||||
std::vector<std::function<void ()>> cleanup_funcs;
|
||||
};
|
||||
|
||||
template <typename T, typename... Args>
|
||||
|
|
|
|||
|
|
@ -782,7 +782,7 @@ std::string nano::uint128_union::to_string_dec () const
|
|||
}
|
||||
|
||||
nano::hash_or_account::hash_or_account (uint64_t value_a) :
|
||||
raw (value_a)
|
||||
raw (value_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ class rpc_handler_interface
|
|||
public:
|
||||
virtual ~rpc_handler_interface () = default;
|
||||
/** Process RPC 1.0 request. */
|
||||
virtual void process_request (std::string const & action, std::string const & body, std::function<void(std::string const &)> response) = 0;
|
||||
virtual void process_request (std::string const & action, std::string const & body, std::function<void (std::string const &)> response) = 0;
|
||||
/** Process RPC 2.0 request. This is called via the IPC API */
|
||||
virtual void process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body, std::function<void(std::shared_ptr<std::string> const &)> response) = 0;
|
||||
virtual void process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body, std::function<void (std::shared_ptr<std::string> const &)> response) = 0;
|
||||
virtual void stop () = 0;
|
||||
virtual void rpc_instance (nano::rpc & rpc) = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@ nano::error nano::rpc_secure_config::deserialize_toml (nano::tomlconfig & toml)
|
|||
}
|
||||
|
||||
nano::rpc_config::rpc_config () :
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
{
|
||||
}
|
||||
|
||||
nano::rpc_config::rpc_config (uint16_t port_a, bool enable_control_a) :
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ()),
|
||||
port (port_a),
|
||||
enable_control (enable_control_a)
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ()),
|
||||
port (port_a),
|
||||
enable_control (enable_control_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ nano::error nano::rpc_config::deserialize_toml (nano::tomlconfig & toml)
|
|||
}
|
||||
|
||||
nano::rpc_process_config::rpc_process_config () :
|
||||
ipc_address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
ipc_address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ std::vector<nano::stat_histogram::bin> nano::stat_histogram::get_bins () const
|
|||
}
|
||||
|
||||
nano::stat::stat (nano::stat_config config) :
|
||||
config (config)
|
||||
config (config)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -516,12 +516,12 @@ public:
|
|||
* To avoid recursion, the observer callback must only use the received data point snapshop, not query the stat object.
|
||||
* @param observer The observer receives a snapshot of the current samples.
|
||||
*/
|
||||
void observe_sample (stat::type type, stat::detail detail, stat::dir dir, std::function<void(boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
void observe_sample (stat::type type, stat::detail detail, stat::dir dir, std::function<void (boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
{
|
||||
get_entry (key_of (type, detail, dir))->sample_observers.add (observer);
|
||||
}
|
||||
|
||||
void observe_sample (stat::type type, stat::dir dir, std::function<void(boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
void observe_sample (stat::type type, stat::dir dir, std::function<void (boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
{
|
||||
observe_sample (type, stat::detail::all, dir, observer);
|
||||
}
|
||||
|
|
@ -531,7 +531,7 @@ public:
|
|||
* To avoid recursion, the observer callback must only use the received counts, not query the stat object.
|
||||
* @param observer The observer receives the old and the new count.
|
||||
*/
|
||||
void observe_count (stat::type type, stat::detail detail, stat::dir dir, std::function<void(uint64_t, uint64_t)> observer)
|
||||
void observe_count (stat::type type, stat::detail detail, stat::dir dir, std::function<void (uint64_t, uint64_t)> observer)
|
||||
{
|
||||
get_entry (key_of (type, detail, dir))->count_observers.add (observer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,14 +120,14 @@ void nano::thread_attributes::set (boost::thread::attributes & attrs)
|
|||
}
|
||||
|
||||
nano::thread_runner::thread_runner (boost::asio::io_context & io_ctx_a, unsigned service_threads_a) :
|
||||
io_guard (boost::asio::make_work_guard (io_ctx_a))
|
||||
io_guard (boost::asio::make_work_guard (io_ctx_a))
|
||||
{
|
||||
boost::thread::attributes attrs;
|
||||
nano::thread_attributes::set (attrs);
|
||||
auto count = (is_sanitizer_build && nano::network_constants{}.is_dev_network ()) ? 1 : service_threads_a; // This is a workaround to a bad interaction between TSAN, multiple coroutines, and multiple threads servicing io_context. Only use 1 thread if sanitizers are attached
|
||||
for (auto i (0u); i < count; ++i)
|
||||
{
|
||||
threads.emplace_back (attrs, [&io_ctx_a]() {
|
||||
threads.emplace_back (attrs, [&io_ctx_a] () {
|
||||
nano::thread_role::set (nano::thread_role::name::io);
|
||||
try
|
||||
{
|
||||
|
|
@ -197,8 +197,8 @@ void nano::thread_runner::stop_event_processing ()
|
|||
}
|
||||
|
||||
nano::thread_pool::thread_pool (unsigned num_threads, nano::thread_role::name thread_name) :
|
||||
num_threads (num_threads),
|
||||
thread_pool_m (std::make_unique<boost::asio::thread_pool> (num_threads))
|
||||
num_threads (num_threads),
|
||||
thread_pool_m (std::make_unique<boost::asio::thread_pool> (num_threads))
|
||||
{
|
||||
set_thread_names (num_threads, thread_name);
|
||||
}
|
||||
|
|
@ -226,26 +226,26 @@ void nano::thread_pool::stop ()
|
|||
}
|
||||
}
|
||||
|
||||
void nano::thread_pool::push_task (std::function<void()> task)
|
||||
void nano::thread_pool::push_task (std::function<void ()> task)
|
||||
{
|
||||
++num_tasks;
|
||||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
if (!stopped)
|
||||
{
|
||||
boost::asio::post (*thread_pool_m, [this, task]() {
|
||||
boost::asio::post (*thread_pool_m, [this, task] () {
|
||||
task ();
|
||||
--num_tasks;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void nano::thread_pool::add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void()> task)
|
||||
void nano::thread_pool::add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void ()> task)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
if (!stopped && thread_pool_m)
|
||||
{
|
||||
auto timer = std::make_shared<boost::asio::steady_timer> (thread_pool_m->get_executor (), expiry_time);
|
||||
timer->async_wait ([this, task, timer](const boost::system::error_code & ec) {
|
||||
timer->async_wait ([this, task, timer] (const boost::system::error_code & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
push_task (task);
|
||||
|
|
@ -270,13 +270,13 @@ void nano::thread_pool::set_thread_names (unsigned num_threads, nano::thread_rol
|
|||
std::vector<std::promise<void>> promises (num_threads);
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve (num_threads);
|
||||
std::transform (promises.begin (), promises.end (), std::back_inserter (futures), [](auto & promise) {
|
||||
std::transform (promises.begin (), promises.end (), std::back_inserter (futures), [] (auto & promise) {
|
||||
return promise.get_future ();
|
||||
});
|
||||
|
||||
for (auto i = 0u; i < num_threads; ++i)
|
||||
{
|
||||
boost::asio::post (*thread_pool_m, [& promise = promises[i], thread_name]() {
|
||||
boost::asio::post (*thread_pool_m, [&promise = promises[i], thread_name] () {
|
||||
nano::thread_role::set (thread_name);
|
||||
promise.set_value ();
|
||||
});
|
||||
|
|
@ -292,6 +292,6 @@ void nano::thread_pool::set_thread_names (unsigned num_threads, nano::thread_rol
|
|||
std::unique_ptr<nano::container_info_component> nano::collect_container_info (thread_pool & thread_pool, std::string const & name)
|
||||
{
|
||||
auto composite = std::make_unique<container_info_composite> (name);
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "count", thread_pool.num_queued_tasks (), sizeof (std::function<void()>) }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "count", thread_pool.num_queued_tasks (), sizeof (std::function<void ()>) }));
|
||||
return composite;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,10 +169,10 @@ public:
|
|||
~thread_pool ();
|
||||
|
||||
/** This will run when there is an available thread for execution */
|
||||
void push_task (std::function<void()>);
|
||||
void push_task (std::function<void ()>);
|
||||
|
||||
/** Run a task at a certain point in time */
|
||||
void add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void()> task);
|
||||
void add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void ()> task);
|
||||
|
||||
/** Stops any further pushed tasks from executing */
|
||||
void stop ();
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ std::string typed_unit ()
|
|||
|
||||
template <typename UNIT, typename CLOCK>
|
||||
nano::timer<UNIT, CLOCK>::timer (nano::timer_state state_a, std::string const & description_a) :
|
||||
desc (description_a)
|
||||
desc (description_a)
|
||||
{
|
||||
if (state_a == nano::timer_state::started)
|
||||
{
|
||||
|
|
@ -55,14 +55,14 @@ desc (description_a)
|
|||
|
||||
template <typename UNIT, typename CLOCK>
|
||||
nano::timer<UNIT, CLOCK>::timer (std::string const & description_a) :
|
||||
desc (description_a)
|
||||
desc (description_a)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename UNIT, typename CLOCK>
|
||||
nano::timer<UNIT, CLOCK>::timer (std::string const & description_a, nano::timer<UNIT, CLOCK> * parent_a) :
|
||||
parent (parent_a),
|
||||
desc (description_a)
|
||||
parent (parent_a),
|
||||
desc (description_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
#include <boost/filesystem/convenience.hpp>
|
||||
|
||||
nano::tomlconfig::tomlconfig () :
|
||||
tree (cpptoml::make_table ())
|
||||
tree (cpptoml::make_table ())
|
||||
{
|
||||
error = std::make_shared<nano::error> ();
|
||||
}
|
||||
|
||||
nano::tomlconfig::tomlconfig (std::shared_ptr<cpptoml::table> const & tree_a, std::shared_ptr<nano::error> const & error_a) :
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
|
@ -250,7 +250,7 @@ nano::tomlconfig & nano::tomlconfig::get_config (bool optional, std::string cons
|
|||
|
||||
nano::tomlconfig & nano::tomlconfig::get_config (bool optional, std::string const & key, bool & target, bool default_value)
|
||||
{
|
||||
auto bool_conv = [this, &target, &key, optional](std::string val) {
|
||||
auto bool_conv = [this, &target, &key, optional] (std::string val) {
|
||||
if (val == "true")
|
||||
{
|
||||
target = true;
|
||||
|
|
@ -317,7 +317,7 @@ void nano::tomlconfig::erase_defaults (std::shared_ptr<cpptoml::table> const & b
|
|||
if (arr_other.size () == arr_base.size ())
|
||||
{
|
||||
bool equal = std::equal (arr_other.begin (), arr_other.end (), arr_base.begin (),
|
||||
[](auto const & item1, auto const & item2) -> bool {
|
||||
[] (auto const & item1, auto const & item2) -> bool {
|
||||
return (item1->template as<std::string> ()->get () == item2->template as<std::string> ()->get ());
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
* @param key Array element key. Qualified (dotted) keys are not supported for arrays so this must be called on the correct tomlconfig node.
|
||||
*/
|
||||
template <typename T>
|
||||
tomlconfig & array_entries_required (std::string const & key, std::function<void(T)> callback)
|
||||
tomlconfig & array_entries_required (std::string const & key, std::function<void (T)> callback)
|
||||
{
|
||||
if (tree->contains_qualified (key))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ std::size_t nano::get_filedescriptor_limit ()
|
|||
}
|
||||
|
||||
nano::container_info_composite::container_info_composite (std::string const & name) :
|
||||
name (name)
|
||||
name (name)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ const std::string & nano::container_info_composite::get_name () const
|
|||
}
|
||||
|
||||
nano::container_info_leaf::container_info_leaf (const container_info & info) :
|
||||
info (info)
|
||||
info (info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ template <typename... T>
|
|||
class observer_set final
|
||||
{
|
||||
public:
|
||||
void add (std::function<void(T...)> const & observer_a)
|
||||
void add (std::function<void (T...)> const & observer_a)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
observers.push_back (observer_a);
|
||||
|
|
@ -160,7 +160,7 @@ public:
|
|||
}
|
||||
}
|
||||
nano::mutex mutex{ mutex_identifier (mutexes::observer_set) };
|
||||
std::vector<std::function<void(T...)>> observers;
|
||||
std::vector<std::function<void (T...)>> observers;
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
|
|
|
|||
|
|
@ -199,10 +199,10 @@ double nano::denormalized_multiplier (double const multiplier_a, uint64_t const
|
|||
}
|
||||
|
||||
nano::work_pool::work_pool (unsigned max_threads_a, std::chrono::nanoseconds pow_rate_limiter_a, std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> opencl_a) :
|
||||
ticket (0),
|
||||
done (false),
|
||||
pow_rate_limiter (pow_rate_limiter_a),
|
||||
opencl (opencl_a)
|
||||
ticket (0),
|
||||
done (false),
|
||||
pow_rate_limiter (pow_rate_limiter_a),
|
||||
opencl (opencl_a)
|
||||
{
|
||||
static_assert (ATOMIC_INT_LOCK_FREE == 2, "Atomic int needed");
|
||||
boost::thread::attributes attrs;
|
||||
|
|
@ -215,7 +215,7 @@ opencl (opencl_a)
|
|||
}
|
||||
for (auto i (0u); i < count; ++i)
|
||||
{
|
||||
threads.emplace_back (attrs, [this, i]() {
|
||||
threads.emplace_back (attrs, [this, i] () {
|
||||
nano::thread_role::set (nano::thread_role::name::work);
|
||||
nano::work_thread_reprioritize ();
|
||||
loop (i);
|
||||
|
|
@ -331,7 +331,7 @@ void nano::work_pool::cancel (nano::root const & root_a)
|
|||
++ticket;
|
||||
}
|
||||
}
|
||||
pending.remove_if ([&root_a](decltype (pending)::value_type const & item_a) {
|
||||
pending.remove_if ([&root_a] (decltype (pending)::value_type const & item_a) {
|
||||
bool result{ false };
|
||||
if (item_a.item == root_a)
|
||||
{
|
||||
|
|
@ -356,7 +356,7 @@ void nano::work_pool::stop ()
|
|||
producer_condition.notify_all ();
|
||||
}
|
||||
|
||||
void nano::work_pool::generate (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::function<void(boost::optional<uint64_t> const &)> callback_a)
|
||||
void nano::work_pool::generate (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::function<void (boost::optional<uint64_t> const &)> callback_a)
|
||||
{
|
||||
debug_assert (!root_a.is_zero ());
|
||||
if (!threads.empty ())
|
||||
|
|
@ -394,7 +394,7 @@ boost::optional<uint64_t> nano::work_pool::generate (nano::work_version const ve
|
|||
{
|
||||
std::promise<boost::optional<uint64_t>> work;
|
||||
std::future<boost::optional<uint64_t>> future = work.get_future ();
|
||||
generate (version_a, root_a, difficulty_a, [&work](boost::optional<uint64_t> work_a) {
|
||||
generate (version_a, root_a, difficulty_a, [&work] (boost::optional<uint64_t> work_a) {
|
||||
work.set_value (work_a);
|
||||
});
|
||||
result = future.get ().value ();
|
||||
|
|
|
|||
|
|
@ -47,14 +47,14 @@ class opencl_work;
|
|||
class work_item final
|
||||
{
|
||||
public:
|
||||
work_item (nano::work_version const version_a, nano::root const & item_a, uint64_t difficulty_a, std::function<void(boost::optional<uint64_t> const &)> const & callback_a) :
|
||||
work_item (nano::work_version const version_a, nano::root const & item_a, uint64_t difficulty_a, std::function<void (boost::optional<uint64_t> const &)> const & callback_a) :
|
||||
version (version_a), item (item_a), difficulty (difficulty_a), callback (callback_a)
|
||||
{
|
||||
}
|
||||
nano::work_version const version;
|
||||
nano::root const item;
|
||||
uint64_t const difficulty;
|
||||
std::function<void(boost::optional<uint64_t> const &)> const callback;
|
||||
std::function<void (boost::optional<uint64_t> const &)> const callback;
|
||||
};
|
||||
class work_pool final
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ public:
|
|||
void loop (uint64_t);
|
||||
void stop ();
|
||||
void cancel (nano::root const &);
|
||||
void generate (nano::work_version const, nano::root const &, uint64_t, std::function<void(boost::optional<uint64_t> const &)>);
|
||||
void generate (nano::work_version const, nano::root const &, uint64_t, std::function<void (boost::optional<uint64_t> const &)>);
|
||||
boost::optional<uint64_t> generate (nano::work_version const, nano::root const &, uint64_t);
|
||||
// For tests only
|
||||
boost::optional<uint64_t> generate (nano::root const &);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ boost::property_tree::ptree rpc_request (boost::property_tree::ptree const & req
|
|||
debug_assert (results.size () == 1);
|
||||
|
||||
std::promise<boost::optional<boost::property_tree::ptree>> promise;
|
||||
boost::asio::spawn (ioc, [&ioc, &results, request, &promise](boost::asio::yield_context yield) {
|
||||
boost::asio::spawn (ioc, [&ioc, &results, request, &promise] (boost::asio::yield_context yield) {
|
||||
socket_type socket (ioc);
|
||||
boost::beast::flat_buffer buffer;
|
||||
http::request<http::string_body> req;
|
||||
|
|
@ -377,7 +377,7 @@ int main (int argc, char * const * argv)
|
|||
boost::asio::io_context ioc;
|
||||
|
||||
debug_assert (!nano::signal_handler_impl);
|
||||
nano::signal_handler_impl = [&ioc]() {
|
||||
nano::signal_handler_impl = [&ioc] () {
|
||||
ioc.stop ();
|
||||
};
|
||||
|
||||
|
|
@ -387,7 +387,7 @@ int main (int argc, char * const * argv)
|
|||
tcp::resolver resolver{ ioc };
|
||||
auto const primary_node_results = resolver.resolve ("::1", std::to_string (rpc_port_start));
|
||||
|
||||
std::thread t ([send_count, &ioc, &primary_node_results, &resolver, &node_count, &destination_count]() {
|
||||
std::thread t ([send_count, &ioc, &primary_node_results, &resolver, &node_count, &destination_count] () {
|
||||
for (int i = 0; i < node_count; ++i)
|
||||
{
|
||||
keepalive_rpc (ioc, primary_node_results, peering_port_start + i);
|
||||
|
|
@ -436,7 +436,7 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
|
||||
// Send from genesis account to different accounts and receive the funds
|
||||
boost::asio::spawn (ioc, [&ioc, &primary_node_results, &wallet, destination_account, &send_calls_remaining](boost::asio::yield_context yield) {
|
||||
boost::asio::spawn (ioc, [&ioc, &primary_node_results, &wallet, destination_account, &send_calls_remaining] (boost::asio::yield_context yield) {
|
||||
send_receive (ioc, wallet, nano::genesis_account.to_account (), destination_account->as_string, send_calls_remaining, primary_node_results, yield);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
nano::logger_mt logger{ config.node.logging.min_time_between_log_output };
|
||||
boost::asio::io_context io_ctx;
|
||||
auto opencl (nano::opencl_work::create (config.opencl_enable, config.opencl, logger));
|
||||
nano::work_pool opencl_work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
nano::work_pool opencl_work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a, ticket_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
|
|
@ -114,9 +114,9 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
std::cout << error.get_message () << std::endl;
|
||||
std::exit (1);
|
||||
}
|
||||
rpc_handler = std::make_unique<nano::inprocess_rpc_handler> (*node, ipc_server, config.rpc, [&ipc_server, &workers = node->workers, &io_ctx]() {
|
||||
rpc_handler = std::make_unique<nano::inprocess_rpc_handler> (*node, ipc_server, config.rpc, [&ipc_server, &workers = node->workers, &io_ctx] () {
|
||||
ipc_server.stop ();
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (3), [&io_ctx]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (3), [&io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
});
|
||||
});
|
||||
|
|
@ -137,7 +137,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
}
|
||||
|
||||
debug_assert (!nano::signal_handler_impl);
|
||||
nano::signal_handler_impl = [&io_ctx]() {
|
||||
nano::signal_handler_impl = [&io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
sig_int_or_term = 1;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -172,8 +172,8 @@ int main (int argc, char * const * argv)
|
|||
auto const ledger_unfiltered = node->ledger.cache.rep_weights.get_rep_amounts ();
|
||||
auto const ledger_height = node->ledger.cache.block_count.load ();
|
||||
|
||||
auto get_total = [](decltype (bootstrap_weights.second) const & reps) -> nano::uint128_union {
|
||||
return std::accumulate (reps.begin (), reps.end (), nano::uint128_t{ 0 }, [](auto sum, auto const & rep) { return sum + rep.second; });
|
||||
auto get_total = [] (decltype (bootstrap_weights.second) const & reps) -> nano::uint128_union {
|
||||
return std::accumulate (reps.begin (), reps.end (), nano::uint128_t{ 0 }, [] (auto sum, auto const & rep) { return sum + rep.second; });
|
||||
};
|
||||
|
||||
// Hardcoded weights are filtered to a cummulative weight of 99%, need to do the same for ledger weights
|
||||
|
|
@ -182,7 +182,7 @@ int main (int argc, char * const * argv)
|
|||
std::vector<std::pair<nano::account, nano::uint128_t>> sorted;
|
||||
sorted.reserve (ledger_unfiltered.size ());
|
||||
std::copy (ledger_unfiltered.begin (), ledger_unfiltered.end (), std::back_inserter (sorted));
|
||||
std::sort (sorted.begin (), sorted.end (), [](auto const & left, auto const & right) { return left.second > right.second; });
|
||||
std::sort (sorted.begin (), sorted.end (), [] (auto const & left, auto const & right) { return left.second > right.second; });
|
||||
auto const total_unfiltered = get_total (ledger_unfiltered);
|
||||
nano::uint128_t sum{ 0 };
|
||||
auto target = (total_unfiltered.number () / 100) * 99;
|
||||
|
|
@ -210,7 +210,7 @@ int main (int argc, char * const * argv)
|
|||
|
||||
std::vector<mismatched_t> mismatched;
|
||||
mismatched.reserve (hardcoded.size ());
|
||||
std::transform (hardcoded.begin (), hardcoded.end (), std::back_inserter (mismatched), [&ledger](auto const & rep) {
|
||||
std::transform (hardcoded.begin (), hardcoded.end (), std::back_inserter (mismatched), [&ledger] (auto const & rep) {
|
||||
auto ledger_rep (ledger.find (rep.first));
|
||||
nano::uint128_t ledger_weight = (ledger_rep == ledger.end () ? 0 : ledger_rep->second);
|
||||
auto absolute = ledger_weight > rep.second ? ledger_weight - rep.second : rep.second - ledger_weight;
|
||||
|
|
@ -218,12 +218,12 @@ int main (int argc, char * const * argv)
|
|||
});
|
||||
|
||||
// Sort by descending difference
|
||||
std::sort (mismatched.begin (), mismatched.end (), [](mismatched_t const & left, mismatched_t const & right) { return left.diff > right.diff; });
|
||||
std::sort (mismatched.begin (), mismatched.end (), [] (mismatched_t const & left, mismatched_t const & right) { return left.diff > right.diff; });
|
||||
|
||||
nano::uint128_union const mismatch_total = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint128_t{ 0 }, [](auto sum, mismatched_t const & sample) { return sum + sample.diff.number (); });
|
||||
nano::uint128_union const mismatch_total = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint128_t{ 0 }, [] (auto sum, mismatched_t const & sample) { return sum + sample.diff.number (); });
|
||||
nano::uint128_union const mismatch_mean = mismatch_total.number () / mismatched.size ();
|
||||
|
||||
nano::uint512_union mismatch_variance = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint512_t (0), [M = mismatch_mean.number (), N = mismatched.size ()](nano::uint512_t sum, mismatched_t const & sample) {
|
||||
nano::uint512_union mismatch_variance = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint512_t (0), [M = mismatch_mean.number (), N = mismatched.size ()] (nano::uint512_t sum, mismatched_t const & sample) {
|
||||
auto x = sample.diff.number ();
|
||||
nano::uint512_t const mean_diff = x > M ? x - M : M - x;
|
||||
nano::uint512_t const sqr = mean_diff * mean_diff;
|
||||
|
|
@ -235,20 +235,20 @@ int main (int argc, char * const * argv)
|
|||
|
||||
auto const outlier_threshold = std::max (nano::Gxrb_ratio, mismatch_mean.number () + 1 * mismatch_stddev.number ());
|
||||
decltype (mismatched) outliers;
|
||||
std::copy_if (mismatched.begin (), mismatched.end (), std::back_inserter (outliers), [outlier_threshold](mismatched_t const & sample) {
|
||||
std::copy_if (mismatched.begin (), mismatched.end (), std::back_inserter (outliers), [outlier_threshold] (mismatched_t const & sample) {
|
||||
return sample.diff > outlier_threshold;
|
||||
});
|
||||
|
||||
auto const newcomer_threshold = std::max (nano::Gxrb_ratio, mismatch_mean.number ());
|
||||
std::vector<std::pair<nano::account, nano::uint128_t>> newcomers;
|
||||
std::copy_if (ledger.begin (), ledger.end (), std::back_inserter (newcomers), [&hardcoded](auto const & rep) {
|
||||
std::copy_if (ledger.begin (), ledger.end (), std::back_inserter (newcomers), [&hardcoded] (auto const & rep) {
|
||||
return !hardcoded.count (rep.first) && rep.second;
|
||||
});
|
||||
|
||||
// Sort by descending weight
|
||||
std::sort (newcomers.begin (), newcomers.end (), [](auto const & left, auto const & right) { return left.second > right.second; });
|
||||
std::sort (newcomers.begin (), newcomers.end (), [] (auto const & left, auto const & right) { return left.second > right.second; });
|
||||
|
||||
auto newcomer_entry = [](auto const & rep) {
|
||||
auto newcomer_entry = [] (auto const & rep) {
|
||||
return boost::str (boost::format ("representative %1% hardcoded --- ledger %2%") % rep.first.to_account () % nano::uint128_union (rep.second).format_balance (nano::Mxrb_ratio, 0, true));
|
||||
};
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ int main (int argc, char * const * argv)
|
|||
nano::logger_mt logger;
|
||||
nano::opencl_config config (platform, device, threads);
|
||||
auto opencl (nano::opencl_work::create (true, config, logger));
|
||||
nano::work_pool work_pool (0, std::chrono::nanoseconds (0), opencl ? [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
nano::work_pool work_pool (0, std::chrono::nanoseconds (0), opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
|
|
@ -782,7 +782,7 @@ int main (int argc, char * const * argv)
|
|||
// and inform the user that it needs installing
|
||||
std::vector<int> system_codes;
|
||||
|
||||
auto run_addr2line = [&backtrace_addresses, &base_addresses, &system_codes, &crash_report_filename](bool use_relative_addresses) {
|
||||
auto run_addr2line = [&backtrace_addresses, &base_addresses, &system_codes, &crash_report_filename] (bool use_relative_addresses) {
|
||||
for (auto backtrace_address : backtrace_addresses)
|
||||
{
|
||||
// Find the closest address to it
|
||||
|
|
@ -1321,7 +1321,7 @@ int main (int argc, char * const * argv)
|
|||
command_l << rpc_input_l;
|
||||
}
|
||||
|
||||
auto response_handler_l ([](std::string const & response_a) {
|
||||
auto response_handler_l ([] (std::string const & response_a) {
|
||||
std::cout << response_a;
|
||||
// Terminate as soon as we have the result, even if background threads (like work generation) are running.
|
||||
std::exit (0);
|
||||
|
|
@ -1367,7 +1367,7 @@ int main (int argc, char * const * argv)
|
|||
std::atomic<uint64_t> block_count (0);
|
||||
std::atomic<uint64_t> errors (0);
|
||||
|
||||
auto print_error_message = [&silent, &errors](std::string const & error_message_a) {
|
||||
auto print_error_message = [&silent, &errors] (std::string const & error_message_a) {
|
||||
if (!silent)
|
||||
{
|
||||
static nano::mutex cerr_mutex;
|
||||
|
|
@ -1377,10 +1377,10 @@ int main (int argc, char * const * argv)
|
|||
++errors;
|
||||
};
|
||||
|
||||
auto start_threads = [node, &threads_count, &threads, &mutex, &condition, &finished](const auto & function_a, auto & deque_a) {
|
||||
auto start_threads = [node, &threads_count, &threads, &mutex, &condition, &finished] (const auto & function_a, auto & deque_a) {
|
||||
for (auto i (0U); i < threads_count; ++i)
|
||||
{
|
||||
threads.emplace_back ([&function_a, node, &mutex, &condition, &finished, &deque_a]() {
|
||||
threads.emplace_back ([&function_a, node, &mutex, &condition, &finished, &deque_a] () {
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
nano::unique_lock<nano::mutex> lock (mutex);
|
||||
while (!deque_a.empty () || !finished)
|
||||
|
|
@ -1402,7 +1402,7 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
};
|
||||
|
||||
auto check_account = [&print_error_message, &silent, &count, &block_count](std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::account const & account, nano::account_info const & info) {
|
||||
auto check_account = [&print_error_message, &silent, &count, &block_count] (std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::account const & account, nano::account_info const & info) {
|
||||
++count;
|
||||
if (!silent && (count % 20000) == 0)
|
||||
{
|
||||
|
|
@ -1676,7 +1676,7 @@ int main (int argc, char * const * argv)
|
|||
finished = false;
|
||||
std::deque<std::pair<nano::pending_key, nano::pending_info>> pending;
|
||||
|
||||
auto check_pending = [&print_error_message, &silent, &count](std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & info) {
|
||||
auto check_pending = [&print_error_message, &silent, &count] (std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & info) {
|
||||
++count;
|
||||
if (!silent && (count % 500000) == 0)
|
||||
{
|
||||
|
|
@ -1912,7 +1912,7 @@ int main (int argc, char * const * argv)
|
|||
nano::locked<std::vector<boost::unordered_set<nano::account>>> opened_account_versions_shared (epoch_count);
|
||||
using opened_account_versions_t = decltype (opened_account_versions_shared)::value_type;
|
||||
node->store.accounts_for_each_par (
|
||||
[&opened_account_versions_shared, epoch_count](nano::read_transaction const & /*unused*/, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
|
||||
[&opened_account_versions_shared, epoch_count] (nano::read_transaction const & /*unused*/, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
|
||||
// First cache locally
|
||||
opened_account_versions_t opened_account_versions_l (epoch_count);
|
||||
for (; i != n; ++i)
|
||||
|
|
@ -1949,7 +1949,7 @@ int main (int argc, char * const * argv)
|
|||
nano::locked<boost::unordered_map<nano::account, std::underlying_type_t<nano::epoch>>> unopened_highest_pending_shared;
|
||||
using unopened_highest_pending_t = decltype (unopened_highest_pending_shared)::value_type;
|
||||
node->store.pending_for_each_par (
|
||||
[&unopened_highest_pending_shared, &opened_accounts](nano::read_transaction const & /*unused*/, nano::store_iterator<nano::pending_key, nano::pending_info> i, nano::store_iterator<nano::pending_key, nano::pending_info> n) {
|
||||
[&unopened_highest_pending_shared, &opened_accounts] (nano::read_transaction const & /*unused*/, nano::store_iterator<nano::pending_key, nano::pending_info> i, nano::store_iterator<nano::pending_key, nano::pending_info> n) {
|
||||
// First cache locally
|
||||
unopened_highest_pending_t unopened_highest_pending_l;
|
||||
for (; i != n; ++i)
|
||||
|
|
@ -1975,7 +1975,7 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
});
|
||||
|
||||
auto output_account_version_number = [](auto version, auto num_accounts) {
|
||||
auto output_account_version_number = [] (auto version, auto num_accounts) {
|
||||
std::cout << "Account version " << version << " num accounts: " << num_accounts << "\n";
|
||||
};
|
||||
|
||||
|
|
@ -2041,7 +2041,7 @@ std::istream & operator>> (std::istream & in, uint64_from_hex & out_val)
|
|||
}
|
||||
|
||||
address_library_pair::address_library_pair (uint64_t address, std::string library) :
|
||||
address (address), library (library)
|
||||
address (address), library (library)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ void run (boost::filesystem::path const & data_path, std::vector<std::string> co
|
|||
rpc->start ();
|
||||
|
||||
debug_assert (!nano::signal_handler_impl);
|
||||
nano::signal_handler_impl = [&io_ctx]() {
|
||||
nano::signal_handler_impl = [&io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
sig_int_or_term = 1;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
std::shared_ptr<nano_qt::wallet> gui;
|
||||
nano::set_application_icon (application);
|
||||
auto opencl (nano::opencl_work::create (config.opencl_enable, config.opencl, logger));
|
||||
nano::work_pool work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
nano::work_pool work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
|
|
@ -189,7 +189,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
rpc_process = std::make_unique<boost::process::child> (config.rpc.child_process.rpc_path, "--daemon", "--data_path", data_path, "--network", network);
|
||||
}
|
||||
}
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&]() {
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&] () {
|
||||
ipc.stop ();
|
||||
node->stop ();
|
||||
if (rpc)
|
||||
|
|
@ -209,7 +209,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
#endif
|
||||
runner.stop_event_processing ();
|
||||
});
|
||||
application.postEvent (&processor, new nano_qt::eventloop_event ([&]() {
|
||||
application.postEvent (&processor, new nano_qt::eventloop_event ([&] () {
|
||||
gui = std::make_shared<nano_qt::wallet> (application, processor, *node, wallet, wallet_config.account);
|
||||
splash->close ();
|
||||
gui->start ();
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@ size_t constexpr nano::active_transactions::max_active_elections_frontier_insert
|
|||
constexpr std::chrono::minutes nano::active_transactions::expired_optimistic_election_info_cutoff;
|
||||
|
||||
nano::active_transactions::active_transactions (nano::node & node_a, nano::confirmation_height_processor & confirmation_height_processor_a) :
|
||||
confirmation_height_processor (confirmation_height_processor_a),
|
||||
node (node_a),
|
||||
multipliers_cb (20, 1.),
|
||||
trended_active_multiplier (1.0),
|
||||
generator (node_a.config, node_a.ledger, node_a.wallets, node_a.vote_processor, node_a.history, node_a.network, node_a.stats),
|
||||
check_all_elections_period (node_a.network_params.network.is_dev_network () ? 10ms : 5s),
|
||||
election_time_to_live (node_a.network_params.network.is_dev_network () ? 0s : 2s),
|
||||
prioritized_cutoff (std::max<size_t> (1, node_a.config.active_elections_size / 10)),
|
||||
thread ([this] () {
|
||||
confirmation_height_processor (confirmation_height_processor_a),
|
||||
node (node_a),
|
||||
multipliers_cb (20, 1.),
|
||||
trended_active_multiplier (1.0),
|
||||
generator (node_a.config, node_a.ledger, node_a.wallets, node_a.vote_processor, node_a.history, node_a.network, node_a.stats),
|
||||
check_all_elections_period (node_a.network_params.network.is_dev_network () ? 10ms : 5s),
|
||||
election_time_to_live (node_a.network_params.network.is_dev_network () ? 0s : 2s),
|
||||
prioritized_cutoff (std::max<size_t> (1, node_a.config.active_elections_size / 10)),
|
||||
thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::request_loop);
|
||||
request_loop ();
|
||||
})
|
||||
})
|
||||
{
|
||||
// Register a callback which will get called after a block is cemented
|
||||
confirmation_height_processor.add_cemented_observer ([this] (std::shared_ptr<nano::block> const & callback_block_a) {
|
||||
|
|
@ -1542,13 +1542,13 @@ size_t nano::active_transactions::election_winner_details_size ()
|
|||
}
|
||||
|
||||
nano::cementable_account::cementable_account (nano::account const & account_a, size_t blocks_uncemented_a) :
|
||||
account (account_a), blocks_uncemented (blocks_uncemented_a)
|
||||
account (account_a), blocks_uncemented (blocks_uncemented_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::expired_optimistic_election_info::expired_optimistic_election_info (std::chrono::steady_clock::time_point expired_time_a, nano::account account_a) :
|
||||
expired_time (expired_time_a),
|
||||
account (account_a)
|
||||
expired_time (expired_time_a),
|
||||
account (account_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
std::chrono::milliseconds constexpr nano::block_processor::confirmation_request_delay;
|
||||
|
||||
nano::block_post_events::block_post_events (std::function<nano::read_transaction ()> && get_transaction_a) :
|
||||
get_transaction (std::move (get_transaction_a))
|
||||
get_transaction (std::move (get_transaction_a))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -26,15 +26,15 @@ nano::block_post_events::~block_post_events ()
|
|||
}
|
||||
|
||||
nano::block_processor::block_processor (nano::node & node_a, nano::write_database_queue & write_database_queue_a) :
|
||||
next_log (std::chrono::steady_clock::now ()),
|
||||
node (node_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
state_block_signature_verification (node.checker, node.ledger.network_params.ledger.epochs, node.config, node.logger, node.flags.block_processor_verification_size)
|
||||
next_log (std::chrono::steady_clock::now ()),
|
||||
node (node_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
state_block_signature_verification (node.checker, node.ledger.network_params.ledger.epochs, node.config, node.logger, node.flags.block_processor_verification_size)
|
||||
{
|
||||
state_block_signature_verification.blocks_verified_callback = [this](std::deque<std::pair<nano::unchecked_info, bool>> & items, std::vector<int> const & verifications, std::vector<nano::block_hash> const & hashes, std::vector<nano::signature> const & blocks_signatures) {
|
||||
state_block_signature_verification.blocks_verified_callback = [this] (std::deque<std::pair<nano::unchecked_info, bool>> & items, std::vector<int> const & verifications, std::vector<nano::block_hash> const & hashes, std::vector<nano::signature> const & blocks_signatures) {
|
||||
this->process_verified_state_blocks (items, verifications, hashes, blocks_signatures);
|
||||
};
|
||||
state_block_signature_verification.transition_inactive_callback = [this]() {
|
||||
state_block_signature_verification.transition_inactive_callback = [this] () {
|
||||
if (this->flushing)
|
||||
{
|
||||
{
|
||||
|
|
@ -242,7 +242,7 @@ void nano::block_processor::process_verified_state_blocks (std::deque<std::pair<
|
|||
void nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock_a)
|
||||
{
|
||||
auto scoped_write_guard = write_database_queue.wait (nano::writer::process_batch);
|
||||
block_post_events post_events ([& store = node.store] { return store.tx_begin_read (); });
|
||||
block_post_events post_events ([&store = node.store] { return store.tx_begin_read (); });
|
||||
auto transaction (node.store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending, tables::unchecked }));
|
||||
nano::timer<std::chrono::milliseconds> timer_l;
|
||||
lock_a.lock ();
|
||||
|
|
@ -386,7 +386,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
}
|
||||
if ((info_a.modified > nano::seconds_since_epoch () - 300 && node.block_arrival.recent (hash)) || forced_a)
|
||||
{
|
||||
events_a.events.emplace_back ([this, hash, block = info_a.block, result, watch_work_a, origin_a](nano::transaction const & post_event_transaction_a) { process_live (post_event_transaction_a, hash, block, result, watch_work_a, origin_a); });
|
||||
events_a.events.emplace_back ([this, hash, block = info_a.block, result, watch_work_a, origin_a] (nano::transaction const & post_event_transaction_a) { process_live (post_event_transaction_a, hash, block, result, watch_work_a, origin_a); });
|
||||
}
|
||||
queue_unchecked (transaction_a, hash);
|
||||
/* For send blocks check epoch open unchecked (gap pending).
|
||||
|
|
@ -415,7 +415,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
nano::unchecked_key unchecked_key (block->previous (), hash);
|
||||
node.store.unchecked_put (transaction_a, unchecked_key, info_a);
|
||||
|
||||
events_a.events.emplace_back ([this, hash](nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
events_a.events.emplace_back ([this, hash] (nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_previous);
|
||||
break;
|
||||
|
|
@ -435,7 +435,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
nano::unchecked_key unchecked_key (node.ledger.block_source (transaction_a, *(block)), hash);
|
||||
node.store.unchecked_put (transaction_a, unchecked_key, info_a);
|
||||
|
||||
events_a.events.emplace_back ([this, hash](nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
events_a.events.emplace_back ([this, hash] (nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_source);
|
||||
break;
|
||||
|
|
@ -464,7 +464,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
{
|
||||
node.logger.try_log (boost::str (boost::format ("Old for: %1%") % hash.to_string ()));
|
||||
}
|
||||
events_a.events.emplace_back ([this, block = info_a.block, origin_a](nano::transaction const & post_event_transaction_a) { process_old (post_event_transaction_a, block, origin_a); });
|
||||
events_a.events.emplace_back ([this, block = info_a.block, origin_a] (nano::transaction const & post_event_transaction_a) { process_old (post_event_transaction_a, block, origin_a); });
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::old);
|
||||
break;
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
{
|
||||
node.logger.try_log (boost::str (boost::format ("Bad signature for: %1%") % hash.to_string ()));
|
||||
}
|
||||
events_a.events.emplace_back ([this, hash, info_a](nano::transaction const & /* unused */) { requeue_invalid (hash, info_a); });
|
||||
events_a.events.emplace_back ([this, hash, info_a] (nano::transaction const & /* unused */) { requeue_invalid (hash, info_a); });
|
||||
break;
|
||||
}
|
||||
case nano::process_result::negative_spend:
|
||||
|
|
@ -496,7 +496,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
case nano::process_result::fork:
|
||||
{
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::fork);
|
||||
events_a.events.emplace_back ([this, block](nano::transaction const &) { this->node.active.publish (block); });
|
||||
events_a.events.emplace_back ([this, block] (nano::transaction const &) { this->node.active.publish (block); });
|
||||
if (node.config.logging.ledger_logging ())
|
||||
{
|
||||
node.logger.try_log (boost::str (boost::format ("Fork for: %1% root: %2%") % hash.to_string () % block->root ().to_string ()));
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class block_post_events final
|
|||
public:
|
||||
explicit block_post_events (std::function<nano::read_transaction ()> &&);
|
||||
~block_post_events ();
|
||||
std::deque<std::function<void(nano::read_transaction const &)>> events;
|
||||
std::deque<std::function<void (nano::read_transaction const &)>> events;
|
||||
|
||||
private:
|
||||
std::function<nano::read_transaction ()> get_transaction;
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@
|
|||
#include <algorithm>
|
||||
|
||||
nano::bootstrap_initiator::bootstrap_initiator (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
connections = std::make_shared<nano::bootstrap_connections> (node);
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this]() {
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::bootstrap_connections);
|
||||
connections->run ();
|
||||
}));
|
||||
for (size_t i = 0; i < node.config.bootstrap_initiator_threads; ++i)
|
||||
{
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this]() {
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::bootstrap_initiator);
|
||||
run_bootstrap ();
|
||||
}));
|
||||
|
|
@ -157,7 +157,7 @@ void nano::bootstrap_initiator::lazy_requeue (nano::block_hash const & hash_a, n
|
|||
}
|
||||
}
|
||||
|
||||
void nano::bootstrap_initiator::add_observer (std::function<void(bool)> const & observer_a)
|
||||
void nano::bootstrap_initiator::add_observer (std::function<void (bool)> const & observer_a)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (observers_mutex);
|
||||
observers.push_back (observer_a);
|
||||
|
|
@ -327,7 +327,7 @@ void nano::pulls_cache::add (nano::pull_info const & pull_a)
|
|||
else
|
||||
{
|
||||
// Update existing pull
|
||||
cache.get<account_head_tag> ().modify (existing, [pull_a](nano::cached_pulls & cache_a) {
|
||||
cache.get<account_head_tag> ().modify (existing, [pull_a] (nano::cached_pulls & cache_a) {
|
||||
cache_a.time = std::chrono::steady_clock::now ();
|
||||
cache_a.new_head = pull_a.head;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public:
|
|||
void run_bootstrap ();
|
||||
void lazy_requeue (nano::block_hash const &, nano::block_hash const &, bool);
|
||||
void notify_listeners (bool);
|
||||
void add_observer (std::function<void(bool)> const &);
|
||||
void add_observer (std::function<void (bool)> const &);
|
||||
bool in_progress ();
|
||||
std::shared_ptr<nano::bootstrap_connections> connections;
|
||||
std::shared_ptr<nano::bootstrap_attempt> new_attempt ();
|
||||
|
|
@ -110,7 +110,7 @@ private:
|
|||
nano::mutex mutex;
|
||||
nano::condition_variable condition;
|
||||
nano::mutex observers_mutex;
|
||||
std::vector<std::function<void(bool)>> observers;
|
||||
std::vector<std::function<void (bool)>> observers;
|
||||
std::vector<boost::thread> bootstrap_initiator_threads;
|
||||
|
||||
friend std::unique_ptr<container_info_component> collect_container_info (bootstrap_initiator & bootstrap_initiator, std::string const & name);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ constexpr unsigned nano::bootstrap_limits::requeued_pulls_limit;
|
|||
constexpr unsigned nano::bootstrap_limits::requeued_pulls_limit_dev;
|
||||
|
||||
nano::bootstrap_attempt::bootstrap_attempt (std::shared_ptr<nano::node> const & node_a, nano::bootstrap_mode mode_a, uint64_t incremental_id_a, std::string id_a) :
|
||||
node (node_a),
|
||||
incremental_id (incremental_id_a),
|
||||
id (id_a),
|
||||
mode (mode_a)
|
||||
node (node_a),
|
||||
incremental_id (incremental_id_a),
|
||||
id (id_a),
|
||||
mode (mode_a)
|
||||
{
|
||||
if (id.empty ())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,23 +8,23 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::pull_info::pull_info (nano::hash_or_account const & account_or_head_a, nano::block_hash const & head_a, nano::block_hash const & end_a, uint64_t bootstrap_id_a, count_t count_a, unsigned retry_limit_a) :
|
||||
account_or_head (account_or_head_a),
|
||||
head (head_a),
|
||||
head_original (head_a),
|
||||
end (end_a),
|
||||
count (count_a),
|
||||
retry_limit (retry_limit_a),
|
||||
bootstrap_id (bootstrap_id_a)
|
||||
account_or_head (account_or_head_a),
|
||||
head (head_a),
|
||||
head_original (head_a),
|
||||
end (end_a),
|
||||
count (count_a),
|
||||
retry_limit (retry_limit_a),
|
||||
bootstrap_id (bootstrap_id_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_pull_client::bulk_pull_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, nano::pull_info const & pull_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
known_account (0),
|
||||
pull (pull_a),
|
||||
pull_blocks (0),
|
||||
unexpected_count (0)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
known_account (0),
|
||||
pull (pull_a),
|
||||
pull_blocks (0),
|
||||
unexpected_count (0)
|
||||
{
|
||||
attempt->condition.notify_all ();
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ void nano::bulk_pull_client::request ()
|
|||
}
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
req, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
req, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->throttled_receive_block ();
|
||||
|
|
@ -110,7 +110,7 @@ void nano::bulk_pull_client::throttled_receive_block ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l]() {
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l] () {
|
||||
if (!this_l->connection->pending_stop && !this_l->attempt->stopped)
|
||||
{
|
||||
this_l->throttled_receive_block ();
|
||||
|
|
@ -122,7 +122,7 @@ void nano::bulk_pull_client::throttled_receive_block ()
|
|||
void nano::bulk_pull_client::receive_block ()
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_read (connection->receive_buffer, 1, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (connection->receive_buffer, 1, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->received_type ();
|
||||
|
|
@ -149,35 +149,35 @@ void nano::bulk_pull_client::received_type ()
|
|||
{
|
||||
case nano::block_type::send:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::send_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::send_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::receive:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::receive_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::receive_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::open:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::open_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::open_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::change:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::change_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::change_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::state:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::state_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::state_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
@ -285,10 +285,10 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e
|
|||
}
|
||||
|
||||
nano::bulk_pull_account_client::bulk_pull_account_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, nano::account const & account_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
account (account_a),
|
||||
pull_blocks (0)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
account (account_a),
|
||||
pull_blocks (0)
|
||||
{
|
||||
attempt->condition.notify_all ();
|
||||
}
|
||||
|
|
@ -314,7 +314,7 @@ void nano::bulk_pull_account_client::request ()
|
|||
}
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
req, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
req, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->receive_pending ();
|
||||
|
|
@ -336,7 +336,7 @@ void nano::bulk_pull_account_client::receive_pending ()
|
|||
{
|
||||
auto this_l (shared_from_this ());
|
||||
size_t size_l (sizeof (nano::uint256_union) + sizeof (nano::uint128_union));
|
||||
connection->socket->async_read (connection->receive_buffer, size_l, [this_l, size_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (connection->receive_buffer, size_l, [this_l, size_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
// An issue with asio is that sometimes, instead of reporting a bad file descriptor during disconnect,
|
||||
// we simply get a size of 0.
|
||||
if (size_a == size_l)
|
||||
|
|
@ -494,7 +494,7 @@ void nano::bulk_pull_server::send_next ()
|
|||
{
|
||||
connection->node->logger.try_log (boost::str (boost::format ("Sending block: %1%") % block->hash ().to_string ()));
|
||||
}
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -598,7 +598,7 @@ void nano::bulk_pull_server::send_finished ()
|
|||
{
|
||||
connection->node->logger.try_log ("Bulk sending finished");
|
||||
}
|
||||
connection->socket->async_write (send_buffer, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (send_buffer, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->no_block_sent (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -620,8 +620,8 @@ void nano::bulk_pull_server::no_block_sent (boost::system::error_code const & ec
|
|||
}
|
||||
|
||||
nano::bulk_pull_server::bulk_pull_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::bulk_pull> request_a) :
|
||||
connection (connection_a),
|
||||
request (std::move (request_a))
|
||||
connection (connection_a),
|
||||
request (std::move (request_a))
|
||||
{
|
||||
set_current_end ();
|
||||
}
|
||||
|
|
@ -700,7 +700,7 @@ void nano::bulk_pull_account_server::send_frontier ()
|
|||
|
||||
// Send the buffer to the requestor
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -756,7 +756,7 @@ void nano::bulk_pull_account_server::send_next_block ()
|
|||
}
|
||||
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -903,7 +903,7 @@ void nano::bulk_pull_account_server::send_finished ()
|
|||
connection->node->logger.try_log ("Bulk sending for an account finished");
|
||||
}
|
||||
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->complete (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -940,9 +940,9 @@ void nano::bulk_pull_account_server::complete (boost::system::error_code const &
|
|||
}
|
||||
|
||||
nano::bulk_pull_account_server::bulk_pull_account_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::bulk_pull_account> request_a) :
|
||||
connection (connection_a),
|
||||
request (std::move (request_a)),
|
||||
current_key (0, 0)
|
||||
connection (connection_a),
|
||||
request (std::move (request_a)),
|
||||
current_key (0, 0)
|
||||
{
|
||||
/*
|
||||
* Setup the streaming response for the first call to "send_frontier" and "send_next_block"
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::bulk_push_client::bulk_push_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ void nano::bulk_push_client::start ()
|
|||
nano::bulk_push message;
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
message, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
message, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->push ();
|
||||
|
|
@ -77,7 +77,7 @@ void nano::bulk_push_client::send_finished ()
|
|||
{
|
||||
nano::shared_const_buffer buffer (static_cast<uint8_t> (nano::block_type::not_a_block));
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send_buffer (buffer, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->channel->send_buffer (buffer, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
try
|
||||
{
|
||||
this_l->promise.set_value (false);
|
||||
|
|
@ -96,7 +96,7 @@ void nano::bulk_push_client::push_block (nano::block const & block_a)
|
|||
nano::serialize_block (stream, block_a);
|
||||
}
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send_buffer (nano::shared_const_buffer (std::move (buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->channel->send_buffer (nano::shared_const_buffer (std::move (buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->push ();
|
||||
|
|
@ -112,8 +112,8 @@ void nano::bulk_push_client::push_block (nano::block const & block_a)
|
|||
}
|
||||
|
||||
nano::bulk_push_server::bulk_push_server (std::shared_ptr<nano::bootstrap_server> const & connection_a) :
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
connection (connection_a)
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
connection (connection_a)
|
||||
{
|
||||
receive_buffer->resize (256);
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ void nano::bulk_push_server::throttled_receive ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l]() {
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l] () {
|
||||
if (!this_l->connection->stopped)
|
||||
{
|
||||
this_l->throttled_receive ();
|
||||
|
|
@ -148,7 +148,7 @@ void nano::bulk_push_server::receive ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_read (receive_buffer, 1, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, 1, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->received_type ();
|
||||
|
|
@ -173,7 +173,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::send:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::send, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::send_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::send_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
@ -181,7 +181,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::receive:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::receive, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::receive_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::receive_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
@ -189,7 +189,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::open:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::open, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::open_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::open_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
@ -197,7 +197,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::change:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::change, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::change_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::change_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
@ -205,7 +205,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::state:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::state_block, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::state_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::state_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ constexpr unsigned nano::bootstrap_limits::bootstrap_max_new_connections;
|
|||
constexpr unsigned nano::bootstrap_limits::requeued_pulls_processed_blocks_factor;
|
||||
|
||||
nano::bootstrap_client::bootstrap_client (std::shared_ptr<nano::node> const & node_a, std::shared_ptr<nano::bootstrap_connections> const & connections_a, std::shared_ptr<nano::transport::channel_tcp> const & channel_a, std::shared_ptr<nano::socket> const & socket_a) :
|
||||
node (node_a),
|
||||
connections (connections_a),
|
||||
channel (channel_a),
|
||||
socket (socket_a),
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
start_time_m (std::chrono::steady_clock::now ())
|
||||
node (node_a),
|
||||
connections (connections_a),
|
||||
channel (channel_a),
|
||||
socket (socket_a),
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
start_time_m (std::chrono::steady_clock::now ())
|
||||
{
|
||||
++connections->connections_count;
|
||||
receive_buffer->resize (256);
|
||||
|
|
@ -60,14 +60,14 @@ void nano::bootstrap_client::stop (bool force)
|
|||
}
|
||||
|
||||
nano::bootstrap_connections::bootstrap_connections (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<nano::bootstrap_client> nano::bootstrap_connections::connection (std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, bool use_front_connection)
|
||||
{
|
||||
nano::unique_lock<nano::mutex> lock (mutex);
|
||||
condition.wait (lock, [& stopped = stopped, &idle = idle, &new_connections_empty = new_connections_empty] { return stopped || !idle.empty () || new_connections_empty; });
|
||||
condition.wait (lock, [&stopped = stopped, &idle = idle, &new_connections_empty = new_connections_empty] { return stopped || !idle.empty () || new_connections_empty; });
|
||||
std::shared_ptr<nano::bootstrap_client> result;
|
||||
if (!stopped && !idle.empty ())
|
||||
{
|
||||
|
|
@ -147,7 +147,7 @@ void nano::bootstrap_connections::connect_client (nano::tcp_endpoint const & end
|
|||
auto socket (std::make_shared<nano::socket> (node));
|
||||
auto this_l (shared_from_this ());
|
||||
socket->async_connect (endpoint_a,
|
||||
[this_l, socket, endpoint_a, push_front](boost::system::error_code const & ec) {
|
||||
[this_l, socket, endpoint_a, push_front] (boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
if (this_l->node.config.logging.bulk_pull_logging ())
|
||||
|
|
@ -304,7 +304,7 @@ void nano::bootstrap_connections::populate_connections (bool repeat)
|
|||
if (!stopped && repeat)
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_connections> this_w (shared_from_this ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_w]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->populate_connections ();
|
||||
|
|
@ -358,7 +358,7 @@ void nano::bootstrap_connections::request_pull (nano::unique_lock<nano::mutex> &
|
|||
{
|
||||
// The bulk_pull_client destructor attempt to requeue_pull which can cause a deadlock if this is the last reference
|
||||
// Dispatch request in an external thread in case it needs to be destroyed
|
||||
node.background ([connection_l, attempt_l, pull]() {
|
||||
node.background ([connection_l, attempt_l, pull] () {
|
||||
auto client (std::make_shared<nano::bulk_pull_client> (connection_l, attempt_l, pull));
|
||||
client->request ();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ void nano::frontier_req_client::run (nano::account const & start_account_a, uint
|
|||
next (); // Load accounts from disk
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
request, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
request, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->receive_frontier ();
|
||||
|
|
@ -41,17 +41,17 @@ void nano::frontier_req_client::run (nano::account const & start_account_a, uint
|
|||
}
|
||||
|
||||
nano::frontier_req_client::frontier_req_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
count (0),
|
||||
bulk_push_cost (0)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
count (0),
|
||||
bulk_push_cost (0)
|
||||
{
|
||||
}
|
||||
|
||||
void nano::frontier_req_client::receive_frontier ()
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_read (connection->receive_buffer, nano::frontier_req_client::size_frontier, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (connection->receive_buffer, nano::frontier_req_client::size_frontier, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
// An issue with asio is that sometimes, instead of reporting a bad file descriptor during disconnect,
|
||||
// we simply get a size of 0.
|
||||
if (size_a == nano::frontier_req_client::size_frontier)
|
||||
|
|
@ -234,11 +234,11 @@ void nano::frontier_req_client::next ()
|
|||
}
|
||||
|
||||
nano::frontier_req_server::frontier_req_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::frontier_req> request_a) :
|
||||
connection (connection_a),
|
||||
current (request_a->start.number () - 1),
|
||||
frontier (0),
|
||||
request (std::move (request_a)),
|
||||
count (0)
|
||||
connection (connection_a),
|
||||
current (request_a->start.number () - 1),
|
||||
frontier (0),
|
||||
request (std::move (request_a)),
|
||||
count (0)
|
||||
{
|
||||
next ();
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ void nano::frontier_req_server::send_next ()
|
|||
connection->node->logger.try_log (boost::str (boost::format ("Sending frontier for %1% %2%") % current.to_account () % frontier.to_string ()));
|
||||
}
|
||||
next ();
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ void nano::frontier_req_server::send_finished ()
|
|||
{
|
||||
connection->node->logger.try_log ("Frontier sending finished");
|
||||
}
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->no_block_sent (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ constexpr double nano::bootstrap_limits::lazy_batch_pull_count_resize_ratio;
|
|||
constexpr size_t nano::bootstrap_limits::lazy_blocks_restart_limit;
|
||||
|
||||
nano::bootstrap_attempt_lazy::bootstrap_attempt_lazy (std::shared_ptr<nano::node> const & node_a, uint64_t incremental_id_a, std::string const & id_a) :
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::lazy, incremental_id_a, id_a)
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::lazy, incremental_id_a, id_a)
|
||||
{
|
||||
node->bootstrap_initiator.notify_listeners (true);
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ void nano::bootstrap_attempt_lazy::run ()
|
|||
auto this_l (shared_from_this ());
|
||||
while (still_pulling () && !lazy_has_expired ())
|
||||
{
|
||||
condition.wait (lock, [& stopped = stopped, &pulling = pulling, &lazy_pulls = lazy_pulls, this_l] { return stopped || pulling == 0 || (pulling < nano::bootstrap_limits::bootstrap_connection_scale_target_blocks && !lazy_pulls.empty ()) || this_l->lazy_has_expired (); });
|
||||
condition.wait (lock, [&stopped = stopped, &pulling = pulling, &lazy_pulls = lazy_pulls, this_l] { return stopped || pulling == 0 || (pulling < nano::bootstrap_limits::bootstrap_connection_scale_target_blocks && !lazy_pulls.empty ()) || this_l->lazy_has_expired (); });
|
||||
++iterations;
|
||||
// Flushing lazy pulls
|
||||
lazy_pull_flush (lock);
|
||||
|
|
@ -462,7 +462,7 @@ void nano::bootstrap_attempt_lazy::get_information (boost::property_tree::ptree
|
|||
}
|
||||
|
||||
nano::bootstrap_attempt_wallet::bootstrap_attempt_wallet (std::shared_ptr<nano::node> const & node_a, uint64_t incremental_id_a, std::string id_a) :
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::wallet_lazy, incremental_id_a, id_a)
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::wallet_lazy, incremental_id_a, id_a)
|
||||
{
|
||||
node->bootstrap_initiator.notify_listeners (true);
|
||||
}
|
||||
|
|
@ -485,7 +485,7 @@ void nano::bootstrap_attempt_wallet::request_pending (nano::unique_lock<nano::mu
|
|||
auto this_l (shared_from_this ());
|
||||
// The bulk_pull_account_client destructor attempt to requeue_pull which can cause a deadlock if this is the last reference
|
||||
// Dispatch request in an external thread in case it needs to be destroyed
|
||||
node->background ([connection_l, this_l, account]() {
|
||||
node->background ([connection_l, this_l, account] () {
|
||||
auto client (std::make_shared<nano::bulk_pull_account_client> (connection_l, this_l, account));
|
||||
client->request ();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::bootstrap_attempt_legacy::bootstrap_attempt_legacy (std::shared_ptr<nano::node> const & node_a, uint64_t const incremental_id_a, std::string const & id_a, uint32_t const frontiers_age_a, nano::account const & start_account_a) :
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::legacy, incremental_id_a, id_a),
|
||||
frontiers_age (frontiers_age_a),
|
||||
start_account (start_account_a)
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::legacy, incremental_id_a, id_a),
|
||||
frontiers_age (frontiers_age_a),
|
||||
start_account (start_account_a)
|
||||
{
|
||||
node->bootstrap_initiator.notify_listeners (true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
#include <boost/variant/get.hpp>
|
||||
|
||||
nano::bootstrap_listener::bootstrap_listener (uint16_t port_a, nano::node & node_a) :
|
||||
node (node_a),
|
||||
port (port_a)
|
||||
node (node_a),
|
||||
port (port_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ void nano::bootstrap_listener::start ()
|
|||
throw std::runtime_error (ec.message ());
|
||||
}
|
||||
debug_assert (node.network.endpoint ().port () == listening_socket->listening_port ());
|
||||
listening_socket->on_connection ([this](std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
listening_socket->on_connection ([this] (std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
bool keep_accepting = true;
|
||||
if (ec_a)
|
||||
{
|
||||
|
|
@ -104,9 +104,9 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (bo
|
|||
}
|
||||
|
||||
nano::bootstrap_server::bootstrap_server (std::shared_ptr<nano::socket> const & socket_a, std::shared_ptr<nano::node> const & node_a) :
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
socket (socket_a),
|
||||
node (node_a)
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
socket (socket_a),
|
||||
node (node_a)
|
||||
{
|
||||
receive_buffer->resize (1024);
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ void nano::bootstrap_server::receive ()
|
|||
// Increase timeout to receive TCP header (idle server socket)
|
||||
socket->set_timeout (node->network_params.node.idle_timeout);
|
||||
auto this_l (shared_from_this ());
|
||||
socket->async_read (receive_buffer, 8, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, 8, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
// Set remote_endpoint
|
||||
if (this_l->remote_endpoint.port () == 0)
|
||||
{
|
||||
|
|
@ -182,7 +182,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
case nano::message_type::bulk_pull:
|
||||
{
|
||||
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::bulk_pull, nano::stat::dir::in);
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_bulk_pull_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
|
@ -190,7 +190,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
case nano::message_type::bulk_pull_account:
|
||||
{
|
||||
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::bulk_pull_account, nano::stat::dir::in);
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_bulk_pull_account_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
|
@ -198,7 +198,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
case nano::message_type::frontier_req:
|
||||
{
|
||||
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::frontier_req, nano::stat::dir::in);
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_frontier_req_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
|
@ -214,35 +214,35 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
}
|
||||
case nano::message_type::keepalive:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_keepalive_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::publish:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_publish_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::confirm_ack:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_confirm_ack_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::confirm_req:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_confirm_req_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::node_id_handshake:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_node_id_handshake_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
|
@ -269,7 +269,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
}
|
||||
case nano::message_type::telemetry_ack:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_telemetry_ack_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
|
@ -567,7 +567,7 @@ void nano::bootstrap_server::finish_request ()
|
|||
else
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w]() {
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->timeout ();
|
||||
|
|
@ -579,7 +579,7 @@ void nano::bootstrap_server::finish_request ()
|
|||
void nano::bootstrap_server::finish_request_async ()
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
|
||||
node->background ([this_w]() {
|
||||
node->background ([this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->finish_request ();
|
||||
|
|
@ -677,7 +677,7 @@ public:
|
|||
auto cookie (connection->node->network.syn_cookies.assign (nano::transport::map_tcp_to_endpoint (connection->remote_endpoint)));
|
||||
nano::node_id_handshake response_message (cookie, response);
|
||||
auto shared_const_buffer = response_message.to_shared_const_buffer ();
|
||||
connection->socket->async_write (shared_const_buffer, [connection = std::weak_ptr<nano::bootstrap_server> (connection)](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (shared_const_buffer, [connection = std::weak_ptr<nano::bootstrap_server> (connection)] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (auto connection_l = connection.lock ())
|
||||
{
|
||||
if (ec)
|
||||
|
|
@ -748,7 +748,7 @@ void nano::bootstrap_server::run_next (nano::unique_lock<nano::mutex> & lock_a)
|
|||
if (timeout_check)
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w]() {
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->timeout ();
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ uint64_t nano::ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint1
|
|||
}
|
||||
|
||||
nano::message_header::message_header (nano::message_type type_a) :
|
||||
version_max (get_protocol_constants ().protocol_version),
|
||||
version_using (get_protocol_constants ().protocol_version),
|
||||
type (type_a)
|
||||
version_max (get_protocol_constants ().protocol_version),
|
||||
version_using (get_protocol_constants ().protocol_version),
|
||||
type (type_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -111,12 +111,12 @@ uint8_t nano::message_header::version_min () const
|
|||
}
|
||||
|
||||
nano::message::message (nano::message_type type_a) :
|
||||
header (type_a)
|
||||
header (type_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::message::message (nano::message_header const & header_a) :
|
||||
header (header_a)
|
||||
header (header_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -336,12 +336,12 @@ std::string nano::message_parser::status_string ()
|
|||
}
|
||||
|
||||
nano::message_parser::message_parser (nano::network_filter & publish_filter_a, nano::block_uniquer & block_uniquer_a, nano::vote_uniquer & vote_uniquer_a, nano::message_visitor & visitor_a, nano::work_pool & pool_a) :
|
||||
publish_filter (publish_filter_a),
|
||||
block_uniquer (block_uniquer_a),
|
||||
vote_uniquer (vote_uniquer_a),
|
||||
visitor (visitor_a),
|
||||
pool (pool_a),
|
||||
status (parse_status::success)
|
||||
publish_filter (publish_filter_a),
|
||||
block_uniquer (block_uniquer_a),
|
||||
vote_uniquer (vote_uniquer_a),
|
||||
visitor (visitor_a),
|
||||
pool (pool_a),
|
||||
status (parse_status::success)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ bool nano::message_parser::at_end (nano::stream & stream_a)
|
|||
}
|
||||
|
||||
nano::keepalive::keepalive () :
|
||||
message (nano::message_type::keepalive)
|
||||
message (nano::message_type::keepalive)
|
||||
{
|
||||
nano::endpoint endpoint (boost::asio::ip::address_v6{}, 0);
|
||||
for (auto i (peers.begin ()), n (peers.end ()); i != n; ++i)
|
||||
|
|
@ -568,7 +568,7 @@ message (nano::message_type::keepalive)
|
|||
}
|
||||
|
||||
nano::keepalive::keepalive (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -619,8 +619,8 @@ bool nano::keepalive::operator== (nano::keepalive const & other_a) const
|
|||
}
|
||||
|
||||
nano::publish::publish (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::uint128_t const & digest_a, nano::block_uniquer * uniquer_a) :
|
||||
message (header_a),
|
||||
digest (digest_a)
|
||||
message (header_a),
|
||||
digest (digest_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -629,8 +629,8 @@ digest (digest_a)
|
|||
}
|
||||
|
||||
nano::publish::publish (std::shared_ptr<nano::block> const & block_a) :
|
||||
message (nano::message_type::publish),
|
||||
block (block_a)
|
||||
message (nano::message_type::publish),
|
||||
block (block_a)
|
||||
{
|
||||
header.block_type_set (block->type ());
|
||||
}
|
||||
|
|
@ -661,7 +661,7 @@ bool nano::publish::operator== (nano::publish const & other_a) const
|
|||
}
|
||||
|
||||
nano::confirm_req::confirm_req (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::block_uniquer * uniquer_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -670,15 +670,15 @@ message (header_a)
|
|||
}
|
||||
|
||||
nano::confirm_req::confirm_req (std::shared_ptr<nano::block> const & block_a) :
|
||||
message (nano::message_type::confirm_req),
|
||||
block (block_a)
|
||||
message (nano::message_type::confirm_req),
|
||||
block (block_a)
|
||||
{
|
||||
header.block_type_set (block->type ());
|
||||
}
|
||||
|
||||
nano::confirm_req::confirm_req (std::vector<std::pair<nano::block_hash, nano::root>> const & roots_hashes_a) :
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (roots_hashes_a)
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (roots_hashes_a)
|
||||
{
|
||||
// not_a_block (1) block type for hashes + roots request
|
||||
header.block_type_set (nano::block_type::not_a_block);
|
||||
|
|
@ -687,8 +687,8 @@ roots_hashes (roots_hashes_a)
|
|||
}
|
||||
|
||||
nano::confirm_req::confirm_req (nano::block_hash const & hash_a, nano::root const & root_a) :
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (std::vector<std::pair<nano::block_hash, nano::root>> (1, std::make_pair (hash_a, root_a)))
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (std::vector<std::pair<nano::block_hash, nano::root>> (1, std::make_pair (hash_a, root_a)))
|
||||
{
|
||||
debug_assert (!roots_hashes.empty ());
|
||||
// not_a_block (1) block type for hashes + roots request
|
||||
|
|
@ -801,8 +801,8 @@ size_t nano::confirm_req::size (nano::block_type type_a, size_t count)
|
|||
}
|
||||
|
||||
nano::confirm_ack::confirm_ack (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::vote_uniquer * uniquer_a) :
|
||||
message (header_a),
|
||||
vote (nano::make_shared<nano::vote> (error_a, stream_a, header.block_type ()))
|
||||
message (header_a),
|
||||
vote (nano::make_shared<nano::vote> (error_a, stream_a, header.block_type ()))
|
||||
{
|
||||
if (!error_a && uniquer_a)
|
||||
{
|
||||
|
|
@ -811,8 +811,8 @@ vote (nano::make_shared<nano::vote> (error_a, stream_a, header.block_type ()))
|
|||
}
|
||||
|
||||
nano::confirm_ack::confirm_ack (std::shared_ptr<nano::vote> const & vote_a) :
|
||||
message (nano::message_type::confirm_ack),
|
||||
vote (vote_a)
|
||||
message (nano::message_type::confirm_ack),
|
||||
vote (vote_a)
|
||||
{
|
||||
debug_assert (!vote_a->blocks.empty ());
|
||||
auto & first_vote_block (vote_a->blocks[0]);
|
||||
|
|
@ -861,12 +861,12 @@ size_t nano::confirm_ack::size (nano::block_type type_a, size_t count)
|
|||
}
|
||||
|
||||
nano::frontier_req::frontier_req () :
|
||||
message (nano::message_type::frontier_req)
|
||||
message (nano::message_type::frontier_req)
|
||||
{
|
||||
}
|
||||
|
||||
nano::frontier_req::frontier_req (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -911,12 +911,12 @@ bool nano::frontier_req::operator== (nano::frontier_req const & other_a) const
|
|||
}
|
||||
|
||||
nano::bulk_pull::bulk_pull () :
|
||||
message (nano::message_type::bulk_pull)
|
||||
message (nano::message_type::bulk_pull)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_pull::bulk_pull (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1007,12 +1007,12 @@ void nano::bulk_pull::set_count_present (bool value_a)
|
|||
}
|
||||
|
||||
nano::bulk_pull_account::bulk_pull_account () :
|
||||
message (nano::message_type::bulk_pull_account)
|
||||
message (nano::message_type::bulk_pull_account)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_pull_account::bulk_pull_account (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1052,12 +1052,12 @@ bool nano::bulk_pull_account::deserialize (nano::stream & stream_a)
|
|||
}
|
||||
|
||||
nano::bulk_push::bulk_push () :
|
||||
message (nano::message_type::bulk_push)
|
||||
message (nano::message_type::bulk_push)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_push::bulk_push (nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1078,12 +1078,12 @@ void nano::bulk_push::visit (nano::message_visitor & visitor_a) const
|
|||
}
|
||||
|
||||
nano::telemetry_req::telemetry_req () :
|
||||
message (nano::message_type::telemetry_req)
|
||||
message (nano::message_type::telemetry_req)
|
||||
{
|
||||
}
|
||||
|
||||
nano::telemetry_req::telemetry_req (nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1104,12 +1104,12 @@ void nano::telemetry_req::visit (nano::message_visitor & visitor_a) const
|
|||
}
|
||||
|
||||
nano::telemetry_ack::telemetry_ack () :
|
||||
message (nano::message_type::telemetry_ack)
|
||||
message (nano::message_type::telemetry_ack)
|
||||
{
|
||||
}
|
||||
|
||||
nano::telemetry_ack::telemetry_ack (bool & error_a, nano::stream & stream_a, nano::message_header const & message_header) :
|
||||
message (message_header)
|
||||
message (message_header)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -1118,8 +1118,8 @@ message (message_header)
|
|||
}
|
||||
|
||||
nano::telemetry_ack::telemetry_ack (nano::telemetry_data const & telemetry_data_a) :
|
||||
message (nano::message_type::telemetry_ack),
|
||||
data (telemetry_data_a)
|
||||
message (nano::message_type::telemetry_ack),
|
||||
data (telemetry_data_a)
|
||||
{
|
||||
debug_assert (telemetry_data::size + telemetry_data_a.unknown_data.size () <= message_header::telemetry_size_mask.to_ulong ()); // Maximum size the mask allows
|
||||
header.extensions &= ~message_header::telemetry_size_mask;
|
||||
|
|
@ -1357,17 +1357,17 @@ bool nano::telemetry_data::validate_signature () const
|
|||
}
|
||||
|
||||
nano::node_id_handshake::node_id_handshake (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a),
|
||||
query (boost::none),
|
||||
response (boost::none)
|
||||
message (header_a),
|
||||
query (boost::none),
|
||||
response (boost::none)
|
||||
{
|
||||
error_a = deserialize (stream_a);
|
||||
}
|
||||
|
||||
nano::node_id_handshake::node_id_handshake (boost::optional<nano::uint256_union> query, boost::optional<std::pair<nano::account, nano::signature>> response) :
|
||||
message (nano::message_type::node_id_handshake),
|
||||
query (query),
|
||||
response (response)
|
||||
message (nano::message_type::node_id_handshake),
|
||||
query (query),
|
||||
response (response)
|
||||
{
|
||||
if (query)
|
||||
{
|
||||
|
|
@ -1558,6 +1558,6 @@ std::chrono::seconds nano::telemetry_cache_cutoffs::network_to_time (network_con
|
|||
}
|
||||
|
||||
nano::node_singleton_memory_pool_purge_guard::node_singleton_memory_pool_purge_guard () :
|
||||
cleanup_guard ({ nano::block_memory_pool_purge, nano::purge_shared_ptr_singleton_pool_memory<nano::vote>, nano::purge_shared_ptr_singleton_pool_memory<nano::election>, nano::purge_singleton_inactive_votes_cache_pool_memory })
|
||||
cleanup_guard ({ nano::block_memory_pool_purge, nano::purge_shared_ptr_singleton_pool_memory<nano::vote>, nano::purge_shared_ptr_singleton_pool_memory<nano::election>, nano::purge_singleton_inactive_votes_cache_pool_memory })
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::confirmation_height_bounded::confirmation_height_bounded (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logging const & logging_a, nano::logger_mt & logger_a, std::atomic<bool> & stopped_a, uint64_t & batch_write_size_a, std::function<void (std::vector<std::shared_ptr<nano::block>> const &)> const & notify_observers_callback_a, std::function<void (nano::block_hash const &)> const & notify_block_already_cemented_observers_callback_a, std::function<uint64_t ()> const & awaiting_processing_size_callback_a) :
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -561,34 +561,34 @@ void nano::confirmation_height_bounded::clear_process_vars ()
|
|||
}
|
||||
|
||||
nano::confirmation_height_bounded::receive_chain_details::receive_chain_details (nano::account const & account_a, uint64_t height_a, nano::block_hash const & hash_a, nano::block_hash const & top_level_a, boost::optional<nano::block_hash> next_a, uint64_t bottom_height_a, nano::block_hash const & bottom_most_a) :
|
||||
account (account_a),
|
||||
height (height_a),
|
||||
hash (hash_a),
|
||||
top_level (top_level_a),
|
||||
next (next_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_most (bottom_most_a)
|
||||
account (account_a),
|
||||
height (height_a),
|
||||
hash (hash_a),
|
||||
top_level (top_level_a),
|
||||
next (next_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_most (bottom_most_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_bounded::write_details::write_details (nano::account const & account_a, uint64_t bottom_height_a, nano::block_hash const & bottom_hash_a, uint64_t top_height_a, nano::block_hash const & top_hash_a) :
|
||||
account (account_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_hash (bottom_hash_a),
|
||||
top_height (top_height_a),
|
||||
top_hash (top_hash_a)
|
||||
account (account_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_hash (bottom_hash_a),
|
||||
top_height (top_height_a),
|
||||
top_hash (top_hash_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_bounded::receive_source_pair::receive_source_pair (confirmation_height_bounded::receive_chain_details const & receive_details_a, const block_hash & source_a) :
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_bounded::confirmed_info::confirmed_info (uint64_t confirmed_height_a, nano::block_hash const & iterated_frontier_a) :
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_frontier (iterated_frontier_a)
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_frontier (iterated_frontier_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::confirmation_height_processor::confirmation_height_processor (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logging const & logging_a, nano::logger_mt & logger_a, boost::latch & latch, confirmation_height_mode mode_a) :
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
// clang-format off
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
// clang-format off
|
||||
unbounded_processor (ledger_a, write_database_queue_a, batch_separate_pending_min_time_a, logging_a, logger_a, stopped, batch_write_size, [this](auto & cemented_blocks) { this->notify_observers (cemented_blocks); }, [this](auto const & block_hash_a) { this->notify_observers (block_hash_a); }, [this]() { return this->awaiting_processing_size (); }),
|
||||
bounded_processor (ledger_a, write_database_queue_a, batch_separate_pending_min_time_a, logging_a, logger_a, stopped, batch_write_size, [this](auto & cemented_blocks) { this->notify_observers (cemented_blocks); }, [this](auto const & block_hash_a) { this->notify_observers (block_hash_a); }, [this]() { return this->awaiting_processing_size (); }),
|
||||
// clang-format on
|
||||
thread ([this, &latch, mode_a] () {
|
||||
// clang-format on
|
||||
thread ([this, &latch, mode_a] () {
|
||||
nano::thread_role::set (nano::thread_role::name::confirmation_height_processing);
|
||||
// Do not start running the processing thread until other threads have finished their operations
|
||||
latch.wait ();
|
||||
this->run (mode_a);
|
||||
})
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::confirmation_height_unbounded::confirmation_height_unbounded (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logging const & logging_a, nano::logger_mt & logger_a, std::atomic<bool> & stopped_a, uint64_t & batch_write_size_a, std::function<void (std::vector<std::shared_ptr<nano::block>> const &)> const & notify_observers_callback_a, std::function<void (nano::block_hash const &)> const & notify_block_already_cemented_observers_callback_a, std::function<uint64_t ()> const & awaiting_processing_size_callback_a) :
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -485,23 +485,23 @@ uint64_t nano::confirmation_height_unbounded::block_cache_size () const
|
|||
}
|
||||
|
||||
nano::confirmation_height_unbounded::conf_height_details::conf_height_details (nano::account const & account_a, nano::block_hash const & hash_a, uint64_t height_a, uint64_t num_blocks_confirmed_a, std::vector<nano::block_hash> const & block_callback_data_a) :
|
||||
account (account_a),
|
||||
hash (hash_a),
|
||||
height (height_a),
|
||||
num_blocks_confirmed (num_blocks_confirmed_a),
|
||||
block_callback_data (block_callback_data_a)
|
||||
account (account_a),
|
||||
hash (hash_a),
|
||||
height (height_a),
|
||||
num_blocks_confirmed (num_blocks_confirmed_a),
|
||||
block_callback_data (block_callback_data_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_unbounded::receive_source_pair::receive_source_pair (std::shared_ptr<conf_height_details> const & receive_details_a, const block_hash & source_a) :
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_unbounded::confirmed_iterated_pair::confirmed_iterated_pair (uint64_t confirmed_height_a, uint64_t iterated_height_a) :
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_height (iterated_height_a)
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_height (iterated_height_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
using namespace std::chrono_literals;
|
||||
|
||||
nano::confirmation_solicitor::confirmation_solicitor (nano::network & network_a, nano::node_config const & config_a) :
|
||||
max_block_broadcasts (config_a.network_params.network.is_dev_network () ? 4 : 30),
|
||||
max_election_requests (50),
|
||||
max_election_broadcasts (std::max<size_t> (network_a.fanout () / 2, 1)),
|
||||
network (network_a),
|
||||
config (config_a)
|
||||
max_block_broadcasts (config_a.network_params.network.is_dev_network () ? 4 : 30),
|
||||
max_election_requests (50),
|
||||
max_election_broadcasts (std::max<size_t> (network_a.fanout () / 2, 1)),
|
||||
network (network_a),
|
||||
config (config_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <vector>
|
||||
|
||||
nano::daemon_config::daemon_config (boost::filesystem::path const & data_path_a) :
|
||||
data_path (data_path_a)
|
||||
data_path (data_path_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ std::shared_ptr<request_type> nano::distributed_work::peer_request::get_prepared
|
|||
}
|
||||
|
||||
nano::distributed_work::distributed_work (nano::node & node_a, nano::work_request const & request_a, std::chrono::seconds const & backoff_a) :
|
||||
node (node_a),
|
||||
node_w (node_a.shared ()),
|
||||
request (request_a),
|
||||
backoff (backoff_a),
|
||||
strand (node_a.io_ctx.get_executor ()),
|
||||
need_resolve (request_a.peers),
|
||||
elapsed (nano::timer_state::started, "distributed work generation timer")
|
||||
node (node_a),
|
||||
node_w (node_a.shared ()),
|
||||
request (request_a),
|
||||
backoff (backoff_a),
|
||||
strand (node_a.io_ctx.get_executor ()),
|
||||
need_resolve (request_a.peers),
|
||||
elapsed (nano::timer_state::started, "distributed work generation timer")
|
||||
{
|
||||
debug_assert (!finished);
|
||||
debug_assert (status == work_generation_status::ongoing);
|
||||
|
|
@ -82,7 +82,7 @@ void nano::distributed_work::start ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
node.network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (peer.first, std::to_string (peer.second)), [peer, this_l, &extra = resolved_extra](boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
|
||||
node.network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (peer.first, std::to_string (peer.second)), [peer, this_l, &extra = resolved_extra] (boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->do_request (nano::tcp_endpoint (i_a->endpoint ().address (), i_a->endpoint ().port ()));
|
||||
|
|
@ -107,7 +107,7 @@ void nano::distributed_work::start_local ()
|
|||
{
|
||||
auto this_l (shared_from_this ());
|
||||
local_generation_started = true;
|
||||
node.work.generate (request.version, request.root, request.difficulty, [this_l](boost::optional<uint64_t> const & work_a) {
|
||||
node.work.generate (request.version, request.root, request.difficulty, [this_l] (boost::optional<uint64_t> const & work_a) {
|
||||
if (work_a.is_initialized ())
|
||||
{
|
||||
this_l->set_once (*work_a);
|
||||
|
|
@ -134,7 +134,7 @@ void nano::distributed_work::do_request (nano::tcp_endpoint const & endpoint_a)
|
|||
}
|
||||
connection->socket.async_connect (connection->endpoint,
|
||||
boost::asio::bind_executor (strand,
|
||||
[this_l, connection](boost::system::error_code const & ec) {
|
||||
[this_l, connection] (boost::system::error_code const & ec) {
|
||||
if (!ec && !this_l->stopped)
|
||||
{
|
||||
std::string request_string;
|
||||
|
|
@ -154,11 +154,11 @@ void nano::distributed_work::do_request (nano::tcp_endpoint const & endpoint_a)
|
|||
auto peer_request (connection->get_prepared_json_request (request_string));
|
||||
boost::beast::http::async_write (connection->socket, *peer_request,
|
||||
boost::asio::bind_executor (this_l->strand,
|
||||
[this_l, connection, peer_request](boost::system::error_code const & ec, size_t size_a) {
|
||||
[this_l, connection, peer_request] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec && !this_l->stopped)
|
||||
{
|
||||
boost::beast::http::async_read (connection->socket, connection->buffer, connection->response,
|
||||
boost::asio::bind_executor (this_l->strand, [this_l, connection](boost::system::error_code const & ec, size_t size_a) {
|
||||
boost::asio::bind_executor (this_l->strand, [this_l, connection] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec && !this_l->stopped)
|
||||
{
|
||||
if (connection->response.result () == boost::beast::http::status::ok)
|
||||
|
|
@ -202,7 +202,7 @@ void nano::distributed_work::do_cancel (nano::tcp_endpoint const & endpoint_a)
|
|||
auto cancelling_l (std::make_shared<peer_request> (node.io_ctx, endpoint_a));
|
||||
cancelling_l->socket.async_connect (cancelling_l->endpoint,
|
||||
boost::asio::bind_executor (strand,
|
||||
[this_l, cancelling_l](boost::system::error_code const & ec) {
|
||||
[this_l, cancelling_l] (boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
std::string request_string;
|
||||
|
|
@ -217,7 +217,7 @@ void nano::distributed_work::do_cancel (nano::tcp_endpoint const & endpoint_a)
|
|||
auto peer_cancel (cancelling_l->get_prepared_json_request (request_string));
|
||||
boost::beast::http::async_write (cancelling_l->socket, *peer_cancel,
|
||||
boost::asio::bind_executor (this_l->strand,
|
||||
[this_l, peer_cancel, cancelling_l](boost::system::error_code const & ec, size_t bytes_transferred) {
|
||||
[this_l, peer_cancel, cancelling_l] (boost::system::error_code const & ec, size_t bytes_transferred) {
|
||||
if (ec && ec != boost::system::errc::operation_canceled)
|
||||
{
|
||||
this_l->node.logger.try_log (boost::str (boost::format ("Unable to send work_cancel to work_peer %1% %2%: %3% (%4%)") % cancelling_l->endpoint.address () % cancelling_l->endpoint.port () % ec.message () % ec.value ()));
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ struct work_request final
|
|||
nano::root root;
|
||||
uint64_t difficulty;
|
||||
boost::optional<nano::account> const account;
|
||||
std::function<void(boost::optional<uint64_t>)> callback;
|
||||
std::function<void (boost::optional<uint64_t>)> callback;
|
||||
std::vector<std::pair<std::string, uint16_t>> const peers;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <nano/node/node.hpp>
|
||||
|
||||
nano::distributed_work_factory::distributed_work_factory (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ nano::distributed_work_factory::~distributed_work_factory ()
|
|||
stop ();
|
||||
}
|
||||
|
||||
bool nano::distributed_work_factory::make (nano::work_version const version_a, nano::root const & root_a, std::vector<std::pair<std::string, uint16_t>> const & peers_a, uint64_t difficulty_a, std::function<void(boost::optional<uint64_t>)> const & callback_a, boost::optional<nano::account> const & account_a)
|
||||
bool nano::distributed_work_factory::make (nano::work_version const version_a, nano::root const & root_a, std::vector<std::pair<std::string, uint16_t>> const & peers_a, uint64_t difficulty_a, std::function<void (boost::optional<uint64_t>)> const & callback_a, boost::optional<nano::account> const & account_a)
|
||||
{
|
||||
return make (std::chrono::seconds (1), nano::work_request{ version_a, root_a, difficulty_a, account_a, callback_a, peers_a });
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ void nano::distributed_work_factory::cancel (nano::root const & root_a)
|
|||
{
|
||||
nano::lock_guard<nano::mutex> guard_l (mutex);
|
||||
auto root_items_l = items.equal_range (root_a);
|
||||
std::for_each (root_items_l.first, root_items_l.second, [](auto item_l) {
|
||||
std::for_each (root_items_l.first, root_items_l.second, [] (auto item_l) {
|
||||
if (auto distributed_l = item_l.second.lock ())
|
||||
{
|
||||
// Send work_cancel to work peers and stop local work generation
|
||||
|
|
@ -55,7 +55,7 @@ void nano::distributed_work_factory::cleanup_finished ()
|
|||
{
|
||||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
// std::erase_if in c++20
|
||||
auto erase_if = [](decltype (items) & container, auto pred) {
|
||||
auto erase_if = [] (decltype (items) & container, auto pred) {
|
||||
for (auto it = container.begin (), end = container.end (); it != end;)
|
||||
{
|
||||
if (pred (*it))
|
||||
|
|
@ -68,7 +68,7 @@ void nano::distributed_work_factory::cleanup_finished ()
|
|||
}
|
||||
}
|
||||
};
|
||||
erase_if (items, [](decltype (items)::value_type item) { return item.second.expired (); });
|
||||
erase_if (items, [] (decltype (items)::value_type item) { return item.second.expired (); });
|
||||
}
|
||||
|
||||
void nano::distributed_work_factory::stop ()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class distributed_work_factory final
|
|||
public:
|
||||
distributed_work_factory (nano::node &);
|
||||
~distributed_work_factory ();
|
||||
bool make (nano::work_version const, nano::root const &, std::vector<std::pair<std::string, uint16_t>> const &, uint64_t, std::function<void(boost::optional<uint64_t>)> const &, boost::optional<nano::account> const & = boost::none);
|
||||
bool make (nano::work_version const, nano::root const &, std::vector<std::pair<std::string, uint16_t>> const &, uint64_t, std::function<void (boost::optional<uint64_t>)> const &, boost::optional<nano::account> const & = boost::none);
|
||||
bool make (std::chrono::seconds const &, nano::work_request const &);
|
||||
void cancel (nano::root const &);
|
||||
void cleanup_finished ();
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ nano::election_vote_result::election_vote_result (bool replay_a, bool processed_
|
|||
processed = processed_a;
|
||||
}
|
||||
|
||||
nano::election::election (nano::node & node_a, std::shared_ptr<nano::block> const & block_a, std::function<void(std::shared_ptr<nano::block> const &)> const & confirmation_action_a, std::function<void(nano::account const &)> const & live_vote_action_a, bool prioritized_a, nano::election_behavior election_behavior_a) :
|
||||
confirmation_action (confirmation_action_a),
|
||||
live_vote_action (live_vote_action_a),
|
||||
prioritized_m (prioritized_a),
|
||||
behavior (election_behavior_a),
|
||||
node (node_a),
|
||||
status ({ block_a, 0, std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values<std::chrono::milliseconds>::zero (), 0, 1, 0, nano::election_status_type::ongoing }),
|
||||
height (block_a->sideband ().height),
|
||||
root (block_a->root ()),
|
||||
qualified_root (block_a->qualified_root ())
|
||||
nano::election::election (nano::node & node_a, std::shared_ptr<nano::block> const & block_a, std::function<void (std::shared_ptr<nano::block> const &)> const & confirmation_action_a, std::function<void (nano::account const &)> const & live_vote_action_a, bool prioritized_a, nano::election_behavior election_behavior_a) :
|
||||
confirmation_action (confirmation_action_a),
|
||||
live_vote_action (live_vote_action_a),
|
||||
prioritized_m (prioritized_a),
|
||||
behavior (election_behavior_a),
|
||||
node (node_a),
|
||||
status ({ block_a, 0, std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values<std::chrono::milliseconds>::zero (), 0, 1, 0, nano::election_status_type::ongoing }),
|
||||
height (block_a->sideband ().height),
|
||||
root (block_a->root ()),
|
||||
qualified_root (block_a->qualified_root ())
|
||||
{
|
||||
last_votes.emplace (node.network_params.random.not_an_account, nano::vote_info{ std::chrono::steady_clock::now (), 0, block_a->hash () });
|
||||
last_blocks.emplace (block_a->hash (), block_a);
|
||||
|
|
@ -52,7 +52,7 @@ void nano::election::confirm_once (nano::unique_lock<nano::mutex> & lock_a, nano
|
|||
lock_a.unlock ();
|
||||
node.active.add_recently_confirmed (status_l.winner->qualified_root (), status_l.winner->hash ());
|
||||
node.process_confirmed (status_l);
|
||||
node.background ([node_l = node.shared (), status_l, confirmation_action_l = confirmation_action]() {
|
||||
node.background ([node_l = node.shared (), status_l, confirmation_action_l = confirmation_action] () {
|
||||
if (confirmation_action_l)
|
||||
{
|
||||
confirmation_action_l (status_l.winner);
|
||||
|
|
@ -551,7 +551,7 @@ bool nano::election::replace_by_weight (nano::unique_lock<nano::mutex> & lock_a,
|
|||
std::copy (last_tally.begin (), last_tally.end (), std::back_inserter (sorted));
|
||||
lock_a.unlock ();
|
||||
// Sort in ascending order
|
||||
std::sort (sorted.begin (), sorted.end (), [](auto const & left, auto const & right) { return left.second < right.second; });
|
||||
std::sort (sorted.begin (), sorted.end (), [] (auto const & left, auto const & right) { return left.second < right.second; });
|
||||
// Replace if lowest tally is below inactive cache new block weight
|
||||
auto inactive_existing (node.active.find_inactive_votes_cache (hash_a));
|
||||
auto inactive_tally (inactive_existing.status.tally);
|
||||
|
|
@ -560,7 +560,7 @@ bool nano::election::replace_by_weight (nano::unique_lock<nano::mutex> & lock_a,
|
|||
// If count of tally items is less than 10, remove any block without tally
|
||||
for (auto const & [hash, block] : blocks ())
|
||||
{
|
||||
if (std::find_if (sorted.begin (), sorted.end (), [& hash = hash](auto const & item_a) { return item_a.first == hash; }) == sorted.end () && hash != winner_hash)
|
||||
if (std::find_if (sorted.begin (), sorted.end (), [&hash = hash] (auto const & item_a) { return item_a.first == hash; }) == sorted.end () && hash != winner_hash)
|
||||
{
|
||||
replaced_block = hash;
|
||||
break;
|
||||
|
|
@ -630,6 +630,6 @@ std::vector<nano::vote_with_weight_info> nano::election::votes_with_weight () co
|
|||
}
|
||||
}
|
||||
result.reserve (sorted_votes.size ());
|
||||
std::transform (sorted_votes.begin (), sorted_votes.end (), std::back_inserter (result), [](auto const & entry) { return entry.second; });
|
||||
std::transform (sorted_votes.begin (), sorted_votes.end (), std::back_inserter (result), [] (auto const & entry) { return entry.second; });
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ class election final : public std::enable_shared_from_this<nano::election>
|
|||
{
|
||||
// Minimum time between broadcasts of the current winner of an election, as a backup to requesting confirmations
|
||||
std::chrono::milliseconds base_latency () const;
|
||||
std::function<void(std::shared_ptr<nano::block> const &)> confirmation_action;
|
||||
std::function<void(nano::account const &)> live_vote_action;
|
||||
std::function<void (std::shared_ptr<nano::block> const &)> confirmation_action;
|
||||
std::function<void (nano::account const &)> live_vote_action;
|
||||
|
||||
private: // State management
|
||||
enum class state_t
|
||||
|
|
@ -111,7 +111,7 @@ public: // Status
|
|||
nano::election_status status;
|
||||
|
||||
public: // Interface
|
||||
election (nano::node &, std::shared_ptr<nano::block> const &, std::function<void(std::shared_ptr<nano::block> const &)> const &, std::function<void(nano::account const &)> const &, bool, nano::election_behavior);
|
||||
election (nano::node &, std::shared_ptr<nano::block> const &, std::function<void (std::shared_ptr<nano::block> const &)> const &, std::function<void (nano::account const &)> const &, bool, nano::election_behavior);
|
||||
std::shared_ptr<nano::block> find (nano::block_hash const &) const;
|
||||
nano::election_vote_result vote (nano::account const &, uint64_t, nano::block_hash const &);
|
||||
bool publish (std::shared_ptr<nano::block> const & block_a);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::gap_cache::gap_cache (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ void nano::gap_cache::add (nano::block_hash const & hash_a, std::chrono::steady_
|
|||
auto existing (blocks.get<tag_hash> ().find (hash_a));
|
||||
if (existing != blocks.get<tag_hash> ().end ())
|
||||
{
|
||||
blocks.get<tag_hash> ().modify (existing, [time_point_a](nano::gap_information & info) {
|
||||
blocks.get<tag_hash> ().modify (existing, [time_point_a] (nano::gap_information & info) {
|
||||
info.arrival = time_point_a;
|
||||
});
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ void nano::gap_cache::vote (std::shared_ptr<nano::vote> const & vote_a)
|
|||
if (existing != gap_blocks_by_hash.end () && !existing->bootstrap_started)
|
||||
{
|
||||
auto is_new (false);
|
||||
gap_blocks_by_hash.modify (existing, [&is_new, &vote_a](nano::gap_information & info) {
|
||||
gap_blocks_by_hash.modify (existing, [&is_new, &vote_a] (nano::gap_information & info) {
|
||||
auto it = std::find (info.voters.begin (), info.voters.end (), vote_a->account);
|
||||
is_new = (it == info.voters.end ());
|
||||
if (is_new)
|
||||
|
|
@ -58,7 +58,7 @@ void nano::gap_cache::vote (std::shared_ptr<nano::vote> const & vote_a)
|
|||
{
|
||||
if (bootstrap_check (existing->voters, hash))
|
||||
{
|
||||
gap_blocks_by_hash.modify (existing, [](nano::gap_information & info) {
|
||||
gap_blocks_by_hash.modify (existing, [] (nano::gap_information & info) {
|
||||
info.bootstrap_started = true;
|
||||
});
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ bool nano::gap_cache::bootstrap_check (std::vector<nano::account> const & voters
|
|||
void nano::gap_cache::bootstrap_start (nano::block_hash const & hash_a)
|
||||
{
|
||||
auto node_l (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.bootstrap.gap_cache_bootstrap_start_interval, [node_l, hash_a]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.bootstrap.gap_cache_bootstrap_start_interval, [node_l, hash_a] () {
|
||||
if (!node_l->ledger.block_or_pruned_exists (hash_a))
|
||||
{
|
||||
if (!node_l->bootstrap_initiator.in_progress ())
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ auto get_message (nanoapi::Envelope const & envelope)
|
|||
* Mapping from message type to handler function.
|
||||
* @note This must be updated whenever a new message type is added to the Flatbuffers IDL.
|
||||
*/
|
||||
auto nano::ipc::action_handler::handler_map () -> std::unordered_map<nanoapi::Message, std::function<void(nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>
|
||||
auto nano::ipc::action_handler::handler_map () -> std::unordered_map<nanoapi::Message, std::function<void (nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>
|
||||
{
|
||||
static std::unordered_map<nanoapi::Message, std::function<void(nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash> handlers;
|
||||
static std::unordered_map<nanoapi::Message, std::function<void (nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash> handlers;
|
||||
if (handlers.empty ())
|
||||
{
|
||||
handlers.emplace (nanoapi::Message::Message_IsAlive, &nano::ipc::action_handler::on_is_alive);
|
||||
|
|
@ -56,10 +56,10 @@ auto nano::ipc::action_handler::handler_map () -> std::unordered_map<nanoapi::Me
|
|||
}
|
||||
|
||||
nano::ipc::action_handler::action_handler (nano::node & node_a, nano::ipc::ipc_server & server_a, std::weak_ptr<nano::ipc::subscriber> const & subscriber_a, std::shared_ptr<flatbuffers::FlatBufferBuilder> const & builder_a) :
|
||||
flatbuffer_producer (builder_a),
|
||||
node (node_a),
|
||||
ipc_server (server_a),
|
||||
subscriber (subscriber_a)
|
||||
flatbuffer_producer (builder_a),
|
||||
node (node_a),
|
||||
ipc_server (server_a),
|
||||
subscriber (subscriber_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace ipc
|
|||
void on_topic_service_stop (nanoapi::Envelope const & envelope);
|
||||
|
||||
/** Returns a mapping from api message types to handler functions */
|
||||
static auto handler_map () -> std::unordered_map<nanoapi::Message, std::function<void(action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>;
|
||||
static auto handler_map () -> std::unordered_map<nanoapi::Message, std::function<void (action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>;
|
||||
|
||||
private:
|
||||
bool has_access (nanoapi::Envelope const & envelope_a, nano::ipc::access_permission permission_a) const noexcept;
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ boost::optional<boost::filesystem::path> get_api_path ()
|
|||
}
|
||||
|
||||
nano::ipc::flatbuffers_handler::flatbuffers_handler (nano::node & node_a, nano::ipc::ipc_server & ipc_server_a, std::shared_ptr<nano::ipc::subscriber> const & subscriber_a, nano::ipc::ipc_config const & ipc_config_a) :
|
||||
node (node_a),
|
||||
ipc_server (ipc_server_a),
|
||||
subscriber (subscriber_a),
|
||||
ipc_config (ipc_config_a)
|
||||
node (node_a),
|
||||
ipc_server (ipc_server_a),
|
||||
subscriber (subscriber_a),
|
||||
ipc_config (ipc_config_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ std::shared_ptr<flatbuffers::Parser> nano::ipc::flatbuffers_handler::make_flatbu
|
|||
}
|
||||
|
||||
void nano::ipc::flatbuffers_handler::process_json (const uint8_t * message_buffer_a, size_t buffer_size_a,
|
||||
std::function<void(std::shared_ptr<std::string> const &)> const & response_handler)
|
||||
std::function<void (std::shared_ptr<std::string> const &)> const & response_handler)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -109,7 +109,7 @@ std::function<void(std::shared_ptr<std::string> const &)> const & response_handl
|
|||
body += '\0';
|
||||
if (parser->Parse (reinterpret_cast<const char *> (body.data ())))
|
||||
{
|
||||
process (parser->builder_.GetBufferPointer (), parser->builder_.GetSize (), [parser = parser, response_handler](std::shared_ptr<flatbuffers::FlatBufferBuilder> const & fbb) {
|
||||
process (parser->builder_.GetBufferPointer (), parser->builder_.GetSize (), [parser = parser, response_handler] (std::shared_ptr<flatbuffers::FlatBufferBuilder> const & fbb) {
|
||||
// Convert response to JSON
|
||||
auto json (std::make_shared<std::string> ());
|
||||
if (!flatbuffers::GenerateText (*parser, fbb->GetBufferPointer (), json.get ()))
|
||||
|
|
@ -145,7 +145,7 @@ std::function<void(std::shared_ptr<std::string> const &)> const & response_handl
|
|||
}
|
||||
|
||||
void nano::ipc::flatbuffers_handler::process (const uint8_t * message_buffer_a, size_t buffer_size_a,
|
||||
std::function<void(std::shared_ptr<flatbuffers::FlatBufferBuilder> const &)> const & response_handler)
|
||||
std::function<void (std::shared_ptr<flatbuffers::FlatBufferBuilder> const &)> const & response_handler)
|
||||
{
|
||||
auto buffer_l (std::make_shared<flatbuffers::FlatBufferBuilder> ());
|
||||
auto actionhandler (std::make_shared<action_handler> (node, ipc_server, subscriber, buffer_l));
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ namespace ipc
|
|||
* @param response_handler Receives a shared pointer to the flatbuffer builder, from which the buffer and size can be queried
|
||||
* @throw Throws std:runtime_error on deserialization or processing errors
|
||||
*/
|
||||
void process (const uint8_t * message_buffer_a, size_t buffer_size_a, std::function<void(std::shared_ptr<flatbuffers::FlatBufferBuilder> const &)> const & response_handler);
|
||||
void process (const uint8_t * message_buffer_a, size_t buffer_size_a, std::function<void (std::shared_ptr<flatbuffers::FlatBufferBuilder> const &)> const & response_handler);
|
||||
|
||||
/**
|
||||
* Parses a JSON encoded requests into Flatbuffer format, calls process(), yields the result as a JSON string
|
||||
*/
|
||||
void process_json (const uint8_t * message_buffer_a, size_t buffer_size_a, std::function<void(std::shared_ptr<std::string> const &)> const & response_handler);
|
||||
void process_json (const uint8_t * message_buffer_a, size_t buffer_size_a, std::function<void (std::shared_ptr<std::string> const &)> const & response_handler);
|
||||
|
||||
/**
|
||||
* Creates a Flatbuffers parser with the schema preparsed. This can then be used to parse and produce JSON.
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ nano::error nano::ipc::access::deserialize_toml (nano::tomlconfig & toml)
|
|||
nano::error error;
|
||||
if (toml.has_key ("role"))
|
||||
{
|
||||
auto get_role = [this](std::shared_ptr<cpptoml::table> const & role_a) {
|
||||
auto get_role = [this] (std::shared_ptr<cpptoml::table> const & role_a) {
|
||||
nano::ipc::access_role role;
|
||||
std::string id_l (role_a->get_as<std::string> ("id").value_or (""));
|
||||
role.id = id_l;
|
||||
|
|
@ -136,7 +136,7 @@ nano::error nano::ipc::access::deserialize_toml (nano::tomlconfig & toml)
|
|||
|
||||
if (!error && toml.has_key ("user"))
|
||||
{
|
||||
auto get_user = [this, &error](std::shared_ptr<cpptoml::table> const & user_a) {
|
||||
auto get_user = [this, &error] (std::shared_ptr<cpptoml::table> const & user_a) {
|
||||
nano::ipc::access_user user;
|
||||
user.id = user_a->get_as<std::string> ("id").value_or ("");
|
||||
// Check bare flag. The tomlconfig parser stringifies values, so we must retrieve as string.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <nano/node/node.hpp>
|
||||
|
||||
nano::ipc::broker::broker (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ std::shared_ptr<flatbuffers::Parser> nano::ipc::subscriber::get_parser (nano::ip
|
|||
|
||||
void nano::ipc::broker::start ()
|
||||
{
|
||||
node.observers.blocks.add ([this_l = shared_from_this ()](nano::election_status const & status_a, std::vector<nano::vote_with_weight_info> const & votes_a, nano::account const & account_a, nano::amount const & amount_a, bool is_state_send_a) {
|
||||
node.observers.blocks.add ([this_l = shared_from_this ()] (nano::election_status const & status_a, std::vector<nano::vote_with_weight_info> const & votes_a, nano::account const & account_a, nano::amount const & amount_a, bool is_state_send_a) {
|
||||
debug_assert (status_a.type != nano::election_status_type::ongoing);
|
||||
|
||||
try
|
||||
|
|
@ -75,7 +75,7 @@ void subscribe_or_unsubscribe (nano::logger_mt & logger, COLL & subscriber_colle
|
|||
{
|
||||
// Evict subscribers from dead sessions. Also remove current subscriber if unsubscribing.
|
||||
subscriber_collection.erase (std::remove_if (subscriber_collection.begin (), subscriber_collection.end (),
|
||||
[& logger = logger, topic_a, subscriber_a](auto & sub) {
|
||||
[&logger = logger, topic_a, subscriber_a] (auto & sub) {
|
||||
bool remove = false;
|
||||
auto subscriber_l = sub.subscriber.lock ();
|
||||
if (subscriber_l)
|
||||
|
|
@ -119,7 +119,7 @@ void nano::ipc::broker::broadcast (std::shared_ptr<nanoapi::EventConfirmationT>
|
|||
{
|
||||
if (auto subscriber_l = itr->subscriber.lock ())
|
||||
{
|
||||
auto should_filter = [this, &itr, confirmation_a]() {
|
||||
auto should_filter = [this, &itr, confirmation_a] () {
|
||||
debug_assert (itr->topic->options != nullptr);
|
||||
auto conf_filter (itr->topic->options->confirmation_type_filter);
|
||||
|
||||
|
|
@ -194,11 +194,11 @@ void nano::ipc::broker::broadcast (std::shared_ptr<nanoapi::EventConfirmationT>
|
|||
throw nano::error ("Couldn't serialize response to JSON");
|
||||
}
|
||||
|
||||
subscriber_l->async_send_message (reinterpret_cast<uint8_t const *> (json->data ()), json->size (), [json](const nano::error & err) {});
|
||||
subscriber_l->async_send_message (reinterpret_cast<uint8_t const *> (json->data ()), json->size (), [json] (const nano::error & err) {});
|
||||
}
|
||||
else
|
||||
{
|
||||
subscriber_l->async_send_message (fb->GetBufferPointer (), fb->GetSize (), [fb](const nano::error & err) {});
|
||||
subscriber_l->async_send_message (fb->GetBufferPointer (), fb->GetSize (), [fb] (const nano::error & err) {});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ void nano::ipc::broker::service_stop (std::string const & service_name_a)
|
|||
{
|
||||
nanoapi::EventServiceStopT event_stop;
|
||||
auto fb (nano::ipc::flatbuffer_producer::make_buffer (event_stop));
|
||||
subscriber_l->async_send_message (fb->GetBufferPointer (), fb->GetSize (), [fb](const nano::error & err) {});
|
||||
subscriber_l->async_send_message (fb->GetBufferPointer (), fb->GetSize (), [fb] (const nano::error & err) {});
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace ipc
|
|||
* @param length_a Length of payload message in bytes
|
||||
* @param broadcast_completion_handler_a Called once sending is completed
|
||||
*/
|
||||
virtual void async_send_message (uint8_t const * data_a, size_t length_a, std::function<void(nano::error const &)> broadcast_completion_handler_a) = 0;
|
||||
virtual void async_send_message (uint8_t const * data_a, size_t length_a, std::function<void (nano::error const &)> broadcast_completion_handler_a) = 0;
|
||||
/** Returns the unique id of the associated session */
|
||||
virtual uint64_t get_id () const = 0;
|
||||
/** Returns the service name associated with the session */
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public:
|
|||
session_m (session_a)
|
||||
{
|
||||
}
|
||||
virtual void async_send_message (uint8_t const * data_a, size_t length_a, std::function<void(nano::error const &)> broadcast_completion_handler_a) override
|
||||
virtual void async_send_message (uint8_t const * data_a, size_t length_a, std::function<void (nano::error const &)> broadcast_completion_handler_a) override
|
||||
{
|
||||
if (auto session_l = session_m.lock ())
|
||||
{
|
||||
|
|
@ -76,7 +76,7 @@ public:
|
|||
boost::asio::buffer (data_a, length_a)
|
||||
};
|
||||
|
||||
session_l->queued_write (buffers, [broadcast_completion_handler_a, big_endian_length](boost::system::error_code const & ec_a, size_t size_a) {
|
||||
session_l->queued_write (buffers, [broadcast_completion_handler_a, big_endian_length] (boost::system::error_code const & ec_a, size_t size_a) {
|
||||
if (broadcast_completion_handler_a)
|
||||
{
|
||||
nano::error error_l (ec_a);
|
||||
|
|
@ -140,10 +140,10 @@ public:
|
|||
|
||||
/** Write a fixed array of buffers through the queue. Once the last item is completed, the callback is invoked */
|
||||
template <std::size_t N>
|
||||
void queued_write (boost::array<boost::asio::const_buffer, N> & buffers, std::function<void(boost::system::error_code const &, size_t)> callback_a)
|
||||
void queued_write (boost::array<boost::asio::const_buffer, N> & buffers, std::function<void (boost::system::error_code const &, size_t)> callback_a)
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffers, callback_a, this_l]() {
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffers, callback_a, this_l] () {
|
||||
bool write_in_progress = !this_l->send_queue.empty ();
|
||||
auto queue_size = this_l->send_queue.size ();
|
||||
if (queue_size < this_l->queue_size_max)
|
||||
|
|
@ -167,10 +167,10 @@ public:
|
|||
* @note This function explicitely doesn't use nano::shared_const_buffer, as buffers usually originate from Flatbuffers
|
||||
* and copying into the shared_const_buffer vector would impose a significant overhead for large requests and responses.
|
||||
*/
|
||||
void queued_write (boost::asio::const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a)
|
||||
void queued_write (boost::asio::const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a)
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffer_a, callback_a, this_l]() {
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffer_a, callback_a, this_l] () {
|
||||
bool write_in_progress = !this_l->send_queue.empty ();
|
||||
auto queue_size = this_l->send_queue.size ();
|
||||
if (queue_size < this_l->queue_size_max)
|
||||
|
|
@ -191,7 +191,7 @@ public:
|
|||
timer_start (std::chrono::seconds (config_transport.io_timeout));
|
||||
nano::unsafe_async_write (socket, msg.buffer,
|
||||
boost::asio::bind_executor (strand,
|
||||
[msg, this_w](boost::system::error_code ec, std::size_t size_a) {
|
||||
[msg, this_w] (boost::system::error_code ec, std::size_t size_a) {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->timer_cancel ();
|
||||
|
|
@ -215,7 +215,7 @@ public:
|
|||
* no error has occurred. On error, the error is logged, the read cycle stops and the session ends. Clients
|
||||
* are expected to implement reconnect logic.
|
||||
*/
|
||||
void async_read_exactly (void * buff_a, size_t size_a, std::function<void()> const & callback_a)
|
||||
void async_read_exactly (void * buff_a, size_t size_a, std::function<void ()> const & callback_a)
|
||||
{
|
||||
async_read_exactly (buff_a, size_a, std::chrono::seconds (config_transport.io_timeout), callback_a);
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ public:
|
|||
* Async read of exactly \p size_a bytes and a specific \p timeout_a.
|
||||
* @see async_read_exactly (void *, size_t, std::function<void()>)
|
||||
*/
|
||||
void async_read_exactly (void * buff_a, size_t size_a, std::chrono::seconds timeout_a, std::function<void()> const & callback_a)
|
||||
void async_read_exactly (void * buff_a, size_t size_a, std::chrono::seconds timeout_a, std::function<void ()> const & callback_a)
|
||||
{
|
||||
timer_start (timeout_a);
|
||||
auto this_l (this->shared_from_this ());
|
||||
|
|
@ -232,7 +232,7 @@ public:
|
|||
boost::asio::buffer (buff_a, size_a),
|
||||
boost::asio::transfer_exactly (size_a),
|
||||
boost::asio::bind_executor (strand,
|
||||
[this_l, callback_a](boost::system::error_code const & ec, size_t bytes_transferred_a) {
|
||||
[this_l, callback_a] (boost::system::error_code const & ec, size_t bytes_transferred_a) {
|
||||
this_l->timer_cancel ();
|
||||
if (ec == boost::asio::error::broken_pipe || ec == boost::asio::error::connection_aborted || ec == boost::asio::error::connection_reset || ec == boost::asio::error::connection_refused)
|
||||
{
|
||||
|
|
@ -257,7 +257,7 @@ public:
|
|||
// This is called when nano::rpc_handler#process_request is done. We convert to
|
||||
// json and write the response to the ipc socket with a length prefix.
|
||||
auto this_l (this->shared_from_this ());
|
||||
auto response_handler_l ([this_l, request_id_l](std::string const & body) {
|
||||
auto response_handler_l ([this_l, request_id_l] (std::string const & body) {
|
||||
auto big = boost::endian::native_to_big (static_cast<uint32_t> (body.size ()));
|
||||
auto buffer (std::make_shared<std::vector<uint8_t>> ());
|
||||
buffer->insert (buffer->end (), reinterpret_cast<std::uint8_t *> (&big), reinterpret_cast<std::uint8_t *> (&big) + sizeof (std::uint32_t));
|
||||
|
|
@ -268,7 +268,7 @@ public:
|
|||
}
|
||||
|
||||
this_l->timer_start (std::chrono::seconds (this_l->config_transport.io_timeout));
|
||||
this_l->queued_write (boost::asio::buffer (buffer->data (), buffer->size ()), [this_l, buffer](boost::system::error_code const & error_a, size_t size_a) {
|
||||
this_l->queued_write (boost::asio::buffer (buffer->data (), buffer->size ()), [this_l, buffer] (boost::system::error_code const & error_a, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
if (!error_a)
|
||||
{
|
||||
|
|
@ -287,9 +287,9 @@ public:
|
|||
auto body (std::string (reinterpret_cast<char *> (buffer.data ()), buffer.size ()));
|
||||
|
||||
// Note that if the rpc action is async, the shared_ptr<json_handler> lifetime will be extended by the action handler
|
||||
auto handler (std::make_shared<nano::json_handler> (node, server.node_rpc_config, body, response_handler_l, [& server = server]() {
|
||||
auto handler (std::make_shared<nano::json_handler> (node, server.node_rpc_config, body, response_handler_l, [&server = server] () {
|
||||
server.stop ();
|
||||
server.node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (3), [& io_ctx = server.node.io_ctx]() {
|
||||
server.node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (3), [&io_ctx = server.node.io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
});
|
||||
}));
|
||||
|
|
@ -304,7 +304,7 @@ public:
|
|||
|
||||
// Await next request indefinitely
|
||||
buffer.resize (sizeof (buffer_size));
|
||||
async_read_exactly (buffer.data (), buffer.size (), std::chrono::seconds::max (), [this_l]() {
|
||||
async_read_exactly (buffer.data (), buffer.size (), std::chrono::seconds::max (), [this_l] () {
|
||||
auto encoding (this_l->buffer[nano::ipc::preamble_offset::encoding]);
|
||||
this_l->active_encoding = static_cast<nano::ipc::payload_encoding> (encoding);
|
||||
if (this_l->buffer[nano::ipc::preamble_offset::lead] != 'N' || this_l->buffer[nano::ipc::preamble_offset::reserved_1] != 0 || this_l->buffer[nano::ipc::preamble_offset::reserved_2] != 0)
|
||||
|
|
@ -318,11 +318,11 @@ public:
|
|||
{
|
||||
auto allow_unsafe (encoding == static_cast<uint8_t> (nano::ipc::payload_encoding::json_v1_unsafe));
|
||||
// Length of payload
|
||||
this_l->async_read_exactly (&this_l->buffer_size, sizeof (this_l->buffer_size), [this_l, allow_unsafe]() {
|
||||
this_l->async_read_exactly (&this_l->buffer_size, sizeof (this_l->buffer_size), [this_l, allow_unsafe] () {
|
||||
boost::endian::big_to_native_inplace (this_l->buffer_size);
|
||||
this_l->buffer.resize (this_l->buffer_size);
|
||||
// Payload (ptree compliant JSON string)
|
||||
this_l->async_read_exactly (this_l->buffer.data (), this_l->buffer_size, [this_l, allow_unsafe]() {
|
||||
this_l->async_read_exactly (this_l->buffer.data (), this_l->buffer_size, [this_l, allow_unsafe] () {
|
||||
this_l->handle_json_query (allow_unsafe);
|
||||
});
|
||||
});
|
||||
|
|
@ -330,11 +330,11 @@ public:
|
|||
else if (encoding == static_cast<uint8_t> (nano::ipc::payload_encoding::flatbuffers) || encoding == static_cast<uint8_t> (nano::ipc::payload_encoding::flatbuffers_json))
|
||||
{
|
||||
// Length of payload
|
||||
this_l->async_read_exactly (&this_l->buffer_size, sizeof (this_l->buffer_size), [this_l, encoding]() {
|
||||
this_l->async_read_exactly (&this_l->buffer_size, sizeof (this_l->buffer_size), [this_l, encoding] () {
|
||||
boost::endian::big_to_native_inplace (this_l->buffer_size);
|
||||
this_l->buffer.resize (this_l->buffer_size);
|
||||
// Payload (flatbuffers or flatbuffers mappable json)
|
||||
this_l->async_read_exactly (this_l->buffer.data (), this_l->buffer_size, [this_l, encoding]() {
|
||||
this_l->async_read_exactly (this_l->buffer.data (), this_l->buffer_size, [this_l, encoding] () {
|
||||
this_l->session_timer.restart ();
|
||||
|
||||
// Lazily create one Flatbuffers handler instance per session
|
||||
|
|
@ -345,7 +345,7 @@ public:
|
|||
|
||||
if (encoding == static_cast<uint8_t> (nano::ipc::payload_encoding::flatbuffers_json))
|
||||
{
|
||||
this_l->flatbuffers_handler->process_json (this_l->buffer.data (), this_l->buffer_size, [this_l](std::shared_ptr<std::string> const & body) {
|
||||
this_l->flatbuffers_handler->process_json (this_l->buffer.data (), this_l->buffer_size, [this_l] (std::shared_ptr<std::string> const & body) {
|
||||
if (this_l->node.config.logging.log_ipc ())
|
||||
{
|
||||
this_l->node.logger.always_log (boost::str (boost::format ("IPC/Flatbuffer request completed in: %1% %2%") % this_l->session_timer.stop ().count () % this_l->session_timer.unit ()));
|
||||
|
|
@ -357,7 +357,7 @@ public:
|
|||
boost::asio::buffer (body->data (), body->size ())
|
||||
};
|
||||
|
||||
this_l->queued_write (buffers, [this_l, body, big_endian_length](boost::system::error_code const & error_a, size_t size_a) {
|
||||
this_l->queued_write (buffers, [this_l, body, big_endian_length] (boost::system::error_code const & error_a, size_t size_a) {
|
||||
if (!error_a)
|
||||
{
|
||||
this_l->read_next_request ();
|
||||
|
|
@ -371,7 +371,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
this_l->flatbuffers_handler->process (this_l->buffer.data (), this_l->buffer_size, [this_l](std::shared_ptr<flatbuffers::FlatBufferBuilder> const & fbb) {
|
||||
this_l->flatbuffers_handler->process (this_l->buffer.data (), this_l->buffer_size, [this_l] (std::shared_ptr<flatbuffers::FlatBufferBuilder> const & fbb) {
|
||||
if (this_l->node.config.logging.log_ipc ())
|
||||
{
|
||||
this_l->node.logger.always_log (boost::str (boost::format ("IPC/Flatbuffer request completed in: %1% %2%") % this_l->session_timer.stop ().count () % this_l->session_timer.unit ()));
|
||||
|
|
@ -383,7 +383,7 @@ public:
|
|||
boost::asio::buffer (fbb->GetBufferPointer (), fbb->GetSize ())
|
||||
};
|
||||
|
||||
this_l->queued_write (buffers, [this_l, fbb, big_endian_length](boost::system::error_code const & error_a, size_t size_a) {
|
||||
this_l->queued_write (buffers, [this_l, fbb, big_endian_length] (boost::system::error_code const & error_a, size_t size_a) {
|
||||
if (!error_a)
|
||||
{
|
||||
this_l->read_next_request ();
|
||||
|
|
@ -419,7 +419,7 @@ private:
|
|||
{
|
||||
public:
|
||||
boost::asio::const_buffer buffer;
|
||||
std::function<void(boost::system::error_code const &, size_t)> callback;
|
||||
std::function<void (boost::system::error_code const &, size_t)> callback;
|
||||
};
|
||||
size_t const queue_size_max = 64 * 1024;
|
||||
|
||||
|
|
@ -511,7 +511,7 @@ public:
|
|||
// Prepare the next session
|
||||
auto new_session (std::make_shared<session<SOCKET_TYPE>> (server, context (), config_transport));
|
||||
|
||||
acceptor->async_accept (new_session->get_socket (), [this, new_session](boost::system::error_code const & ec) {
|
||||
acceptor->async_accept (new_session->get_socket (), [this, new_session] (boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
new_session->read_next_request ();
|
||||
|
|
@ -561,7 +561,7 @@ private:
|
|||
*/
|
||||
void await_hup_signal (std::shared_ptr<boost::asio::signal_set> const & signals, nano::ipc::ipc_server & server_a)
|
||||
{
|
||||
signals->async_wait ([signals, &server_a](const boost::system::error_code & ec, int signal_number) {
|
||||
signals->async_wait ([signals, &server_a] (const boost::system::error_code & ec, int signal_number) {
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
{
|
||||
std::cout << "Reloading access configuration..." << std::endl;
|
||||
|
|
@ -576,9 +576,9 @@ void await_hup_signal (std::shared_ptr<boost::asio::signal_set> const & signals,
|
|||
}
|
||||
|
||||
nano::ipc::ipc_server::ipc_server (nano::node & node_a, nano::node_rpc_config const & node_rpc_config_a) :
|
||||
node (node_a),
|
||||
node_rpc_config (node_rpc_config_a),
|
||||
broker (std::make_shared<nano::ipc::broker> (node_a))
|
||||
node (node_a),
|
||||
node_rpc_config (node_rpc_config_a),
|
||||
broker (std::make_shared<nano::ipc::broker> (node_a))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,25 +18,25 @@
|
|||
namespace
|
||||
{
|
||||
void construct_json (nano::container_info_component * component, boost::property_tree::ptree & parent);
|
||||
using ipc_json_handler_no_arg_func_map = std::unordered_map<std::string, std::function<void(nano::json_handler *)>>;
|
||||
using ipc_json_handler_no_arg_func_map = std::unordered_map<std::string, std::function<void (nano::json_handler *)>>;
|
||||
ipc_json_handler_no_arg_func_map create_ipc_json_handler_no_arg_func_map ();
|
||||
auto ipc_json_handler_no_arg_funcs = create_ipc_json_handler_no_arg_func_map ();
|
||||
bool block_confirmed (nano::node & node, nano::transaction & transaction, nano::block_hash const & hash, bool include_active, bool include_only_confirmed);
|
||||
const char * epoch_as_string (nano::epoch);
|
||||
}
|
||||
|
||||
nano::json_handler::json_handler (nano::node & node_a, nano::node_rpc_config const & node_rpc_config_a, std::string const & body_a, std::function<void(std::string const &)> const & response_a, std::function<void()> stop_callback_a) :
|
||||
body (body_a),
|
||||
node (node_a),
|
||||
response (response_a),
|
||||
stop_callback (stop_callback_a),
|
||||
node_rpc_config (node_rpc_config_a)
|
||||
nano::json_handler::json_handler (nano::node & node_a, nano::node_rpc_config const & node_rpc_config_a, std::string const & body_a, std::function<void (std::string const &)> const & response_a, std::function<void ()> stop_callback_a) :
|
||||
body (body_a),
|
||||
node (node_a),
|
||||
response (response_a),
|
||||
stop_callback (stop_callback_a),
|
||||
node_rpc_config (node_rpc_config_a)
|
||||
{
|
||||
}
|
||||
|
||||
std::function<void()> nano::json_handler::create_worker_task (std::function<void(std::shared_ptr<nano::json_handler> const &)> const & action_a)
|
||||
std::function<void ()> nano::json_handler::create_worker_task (std::function<void (std::shared_ptr<nano::json_handler> const &)> const & action_a)
|
||||
{
|
||||
return [rpc_l = shared_from_this (), action_a]() {
|
||||
return [rpc_l = shared_from_this (), action_a] () {
|
||||
try
|
||||
{
|
||||
action_a (rpc_l);
|
||||
|
|
@ -539,7 +539,7 @@ void nano::json_handler::account_block_count ()
|
|||
|
||||
void nano::json_handler::account_create ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -726,7 +726,7 @@ void nano::json_handler::account_list ()
|
|||
|
||||
void nano::json_handler::account_move ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -765,7 +765,7 @@ void nano::json_handler::account_move ()
|
|||
|
||||
void nano::json_handler::account_remove ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
auto account (rpc_l->account_impl ());
|
||||
if (!rpc_l->ec)
|
||||
|
|
@ -800,7 +800,7 @@ void nano::json_handler::account_representative ()
|
|||
|
||||
void nano::json_handler::account_representative_set ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([work_generation_enabled = node.work_generation_enabled ()](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([work_generation_enabled = node.work_generation_enabled ()] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
auto account (rpc_l->account_impl ());
|
||||
std::string representative_text (rpc_l->request.get<std::string> ("representative"));
|
||||
|
|
@ -840,7 +840,7 @@ void nano::json_handler::account_representative_set ()
|
|||
auto response_a (rpc_l->response);
|
||||
auto response_data (std::make_shared<boost::property_tree::ptree> (rpc_l->response_l));
|
||||
wallet->change_async (
|
||||
account, representative, [response_a, response_data](std::shared_ptr<nano::block> const & block) {
|
||||
account, representative, [response_a, response_data] (std::shared_ptr<nano::block> const & block) {
|
||||
if (block != nullptr)
|
||||
{
|
||||
response_data->put ("block", block->hash ().to_string ());
|
||||
|
|
@ -896,7 +896,7 @@ void nano::json_handler::accounts_balances ()
|
|||
|
||||
void nano::json_handler::accounts_create ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
auto count (rpc_l->count_impl ());
|
||||
if (!rpc_l->ec)
|
||||
|
|
@ -991,13 +991,13 @@ void nano::json_handler::accounts_pending ()
|
|||
{
|
||||
if (source)
|
||||
{
|
||||
peers_l.sort ([](const auto & child1, const auto & child2) -> bool {
|
||||
peers_l.sort ([] (const auto & child1, const auto & child2) -> bool {
|
||||
return child1.second.template get<nano::uint128_t> ("amount") > child2.second.template get<nano::uint128_t> ("amount");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
peers_l.sort ([](const auto & child1, const auto & child2) -> bool {
|
||||
peers_l.sort ([] (const auto & child1, const auto & child2) -> bool {
|
||||
return child1.second.template get<nano::uint128_t> ("") > child2.second.template get<nano::uint128_t> ("");
|
||||
});
|
||||
}
|
||||
|
|
@ -1462,7 +1462,7 @@ void nano::json_handler::block_create ()
|
|||
{
|
||||
auto rpc_l (shared_from_this ());
|
||||
// Serializes the block contents to the RPC response
|
||||
auto block_response_put_l = [rpc_l, this](nano::block const & block_a) {
|
||||
auto block_response_put_l = [rpc_l, this] (nano::block const & block_a) {
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("hash", block_a.hash ().to_string ());
|
||||
response_l.put ("difficulty", nano::to_string_hex (block_a.difficulty ()));
|
||||
|
|
@ -1484,9 +1484,9 @@ void nano::json_handler::block_create ()
|
|||
rpc_l->response (ostream.str ());
|
||||
};
|
||||
// Wrapper from argument to lambda capture, to extend the block's scope
|
||||
auto get_callback_l = [rpc_l, block_response_put_l](std::shared_ptr<nano::block> const & block_a) {
|
||||
auto get_callback_l = [rpc_l, block_response_put_l] (std::shared_ptr<nano::block> const & block_a) {
|
||||
// Callback upon work generation success or failure
|
||||
return [block_a, rpc_l, block_response_put_l](boost::optional<uint64_t> const & work_a) {
|
||||
return [block_a, rpc_l, block_response_put_l] (boost::optional<uint64_t> const & work_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
if (work_a.is_initialized ())
|
||||
|
|
@ -2760,7 +2760,7 @@ void nano::json_handler::node_id_delete ()
|
|||
|
||||
void nano::json_handler::password_change ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -2783,7 +2783,7 @@ void nano::json_handler::password_change ()
|
|||
|
||||
void nano::json_handler::password_enter ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -2820,7 +2820,7 @@ void nano::json_handler::peers ()
|
|||
boost::property_tree::ptree peers_l;
|
||||
const bool peer_details = request.get<bool> ("peer_details", false);
|
||||
auto peers_list (node.network.list (std::numeric_limits<size_t>::max ()));
|
||||
std::sort (peers_list.begin (), peers_list.end (), [](const auto & lhs, const auto & rhs) {
|
||||
std::sort (peers_list.begin (), peers_list.end (), [] (const auto & lhs, const auto & rhs) {
|
||||
return lhs->get_endpoint () < rhs->get_endpoint ();
|
||||
});
|
||||
for (auto i (peers_list.begin ()), n (peers_list.end ()); i != n; ++i)
|
||||
|
|
@ -2930,7 +2930,7 @@ void nano::json_handler::pending ()
|
|||
if (source || min_version)
|
||||
{
|
||||
auto mid = hash_ptree_pairs.size () <= count ? hash_ptree_pairs.end () : hash_ptree_pairs.begin () + count;
|
||||
std::partial_sort (hash_ptree_pairs.begin (), mid, hash_ptree_pairs.end (), [](const auto & lhs, const auto & rhs) {
|
||||
std::partial_sort (hash_ptree_pairs.begin (), mid, hash_ptree_pairs.end (), [] (const auto & lhs, const auto & rhs) {
|
||||
return lhs.second.template get<nano::uint128_t> ("amount") > rhs.second.template get<nano::uint128_t> ("amount");
|
||||
});
|
||||
for (auto i = 0; i < hash_ptree_pairs.size () && i < count; ++i)
|
||||
|
|
@ -2941,7 +2941,7 @@ void nano::json_handler::pending ()
|
|||
else
|
||||
{
|
||||
auto mid = hash_amount_pairs.size () <= count ? hash_amount_pairs.end () : hash_amount_pairs.begin () + count;
|
||||
std::partial_sort (hash_amount_pairs.begin (), mid, hash_amount_pairs.end (), [](const auto & lhs, const auto & rhs) {
|
||||
std::partial_sort (hash_amount_pairs.begin (), mid, hash_amount_pairs.end (), [] (const auto & lhs, const auto & rhs) {
|
||||
return lhs.second > rhs.second;
|
||||
});
|
||||
|
||||
|
|
@ -2986,7 +2986,7 @@ void nano::json_handler::pending_exists ()
|
|||
|
||||
void nano::json_handler::process ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
const bool watch_work_l = rpc_l->request.get<bool> ("watch_work", true);
|
||||
const bool is_async = rpc_l->request.get<bool> ("async", false);
|
||||
auto block (rpc_l->block_impl (true));
|
||||
|
|
@ -3241,7 +3241,7 @@ void nano::json_handler::receive ()
|
|||
bool generate_work (work == 0); // Disable work generation if "work" option is provided
|
||||
auto response_a (response);
|
||||
wallet->receive_async (
|
||||
hash, representative, node.network_params.ledger.genesis_amount, account, [response_a](std::shared_ptr<nano::block> const & block_a) {
|
||||
hash, representative, node.network_params.ledger.genesis_amount, account, [response_a] (std::shared_ptr<nano::block> const & block_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
|
|
@ -3578,7 +3578,7 @@ void nano::json_handler::send ()
|
|||
auto response_a (response);
|
||||
auto response_data (std::make_shared<boost::property_tree::ptree> (response_l));
|
||||
wallet->send_async (
|
||||
source, destination, amount.number (), [balance, amount, response_a, response_data](std::shared_ptr<nano::block> const & block_a) {
|
||||
source, destination, amount.number (), [balance, amount, response_a, response_data] (std::shared_ptr<nano::block> const & block_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
response_data->put ("block", block_a->hash ().to_string ());
|
||||
|
|
@ -3834,7 +3834,7 @@ void nano::json_handler::telemetry ()
|
|||
debug_assert (channel);
|
||||
if (node.telemetry)
|
||||
{
|
||||
node.telemetry->get_metrics_single_peer_async (channel, [rpc_l](auto const & telemetry_response_a) {
|
||||
node.telemetry->get_metrics_single_peer_async (channel, [rpc_l] (auto const & telemetry_response_a) {
|
||||
if (!telemetry_response_a.error)
|
||||
{
|
||||
nano::jsonconfig config_l;
|
||||
|
|
@ -3905,7 +3905,7 @@ void nano::json_handler::telemetry ()
|
|||
nano::jsonconfig config_l;
|
||||
std::vector<nano::telemetry_data> telemetry_datas;
|
||||
telemetry_datas.reserve (telemetry_responses.size ());
|
||||
std::transform (telemetry_responses.begin (), telemetry_responses.end (), std::back_inserter (telemetry_datas), [](auto const & endpoint_telemetry_data) {
|
||||
std::transform (telemetry_responses.begin (), telemetry_responses.end (), std::back_inserter (telemetry_datas), [] (auto const & endpoint_telemetry_data) {
|
||||
return endpoint_telemetry_data.second;
|
||||
});
|
||||
|
||||
|
|
@ -3961,7 +3961,7 @@ void nano::json_handler::unchecked ()
|
|||
|
||||
void nano::json_handler::unchecked_clear ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto transaction (rpc_l->node.store.tx_begin_write ({ tables::unchecked }));
|
||||
rpc_l->node.store.unchecked_clear (transaction);
|
||||
rpc_l->response_l.put ("success", "");
|
||||
|
|
@ -4140,7 +4140,7 @@ void nano::json_handler::validate_account_number ()
|
|||
|
||||
void nano::json_handler::wallet_add ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -4170,7 +4170,7 @@ void nano::json_handler::wallet_add ()
|
|||
|
||||
void nano::json_handler::wallet_add_watch ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -4270,7 +4270,7 @@ void nano::json_handler::wallet_balances ()
|
|||
|
||||
void nano::json_handler::wallet_change_seed ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
if (!rpc_l->ec)
|
||||
{
|
||||
|
|
@ -4318,7 +4318,7 @@ void nano::json_handler::wallet_contains ()
|
|||
|
||||
void nano::json_handler::wallet_create ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
nano::raw_key seed;
|
||||
auto seed_text (rpc_l->request.get_optional<std::string> ("seed"));
|
||||
if (seed_text.is_initialized () && seed.decode_hex (seed_text.get ()))
|
||||
|
|
@ -4354,7 +4354,7 @@ void nano::json_handler::wallet_create ()
|
|||
|
||||
void nano::json_handler::wallet_destroy ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
std::string wallet_text (rpc_l->request.get<std::string> ("wallet"));
|
||||
nano::wallet_id wallet;
|
||||
if (!wallet.decode_hex (wallet_text))
|
||||
|
|
@ -4637,7 +4637,7 @@ void nano::json_handler::wallet_representative ()
|
|||
|
||||
void nano::json_handler::wallet_representative_set ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
std::string representative_text (rpc_l->request.get<std::string> ("representative"));
|
||||
auto representative (rpc_l->account_impl (representative_text, nano::error_rpc::bad_representative_number));
|
||||
|
|
@ -4679,7 +4679,7 @@ void nano::json_handler::wallet_representative_set ()
|
|||
for (auto & account : accounts)
|
||||
{
|
||||
wallet->change_async (
|
||||
account, representative, [](std::shared_ptr<nano::block> const &) {}, 0, false);
|
||||
account, representative, [] (std::shared_ptr<nano::block> const &) {}, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4826,7 +4826,7 @@ void nano::json_handler::work_generate ()
|
|||
{
|
||||
auto use_peers (request.get<bool> ("use_peers", false));
|
||||
auto rpc_l (shared_from_this ());
|
||||
auto callback = [rpc_l, hash, work_version, this](boost::optional<uint64_t> const & work_a) {
|
||||
auto callback = [rpc_l, hash, work_version, this] (boost::optional<uint64_t> const & work_a) {
|
||||
if (work_a)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
|
|
@ -4924,7 +4924,7 @@ void nano::json_handler::work_get ()
|
|||
|
||||
void nano::json_handler::work_set ()
|
||||
{
|
||||
node.workers.push_task (create_worker_task ([](std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
auto account (rpc_l->account_impl ());
|
||||
auto work (rpc_l->work_optional_impl ());
|
||||
|
|
@ -5011,17 +5011,17 @@ void nano::json_handler::work_peers_clear ()
|
|||
response_errors ();
|
||||
}
|
||||
|
||||
void nano::inprocess_rpc_handler::process_request (std::string const &, std::string const & body_a, std::function<void(std::string const &)> response_a)
|
||||
void nano::inprocess_rpc_handler::process_request (std::string const &, std::string const & body_a, std::function<void (std::string const &)> response_a)
|
||||
{
|
||||
// Note that if the rpc action is async, the shared_ptr<json_handler> lifetime will be extended by the action handler
|
||||
auto handler (std::make_shared<nano::json_handler> (node, node_rpc_config, body_a, response_a, [this]() {
|
||||
auto handler (std::make_shared<nano::json_handler> (node, node_rpc_config, body_a, response_a, [this] () {
|
||||
this->stop_callback ();
|
||||
this->stop ();
|
||||
}));
|
||||
handler->process_request ();
|
||||
}
|
||||
|
||||
void nano::inprocess_rpc_handler::process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body_a, std::function<void(std::shared_ptr<std::string> const &)> response_a)
|
||||
void nano::inprocess_rpc_handler::process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body_a, std::function<void (std::shared_ptr<std::string> const &)> response_a)
|
||||
{
|
||||
std::string body_l = params_a.json_envelope (body_a);
|
||||
auto handler (std::make_shared<nano::ipc::flatbuffers_handler> (node, ipc_server, nullptr, node.config.ipc_config));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class json_handler : public std::enable_shared_from_this<nano::json_handler>
|
|||
{
|
||||
public:
|
||||
json_handler (
|
||||
nano::node &, nano::node_rpc_config const &, std::string const &, std::function<void(std::string const &)> const &, std::function<void()> stop_callback = []() {});
|
||||
nano::node &, nano::node_rpc_config const &, std::string const &, std::function<void (std::string const &)> const &, std::function<void ()> stop_callback = [] () {});
|
||||
void process_request (bool unsafe = false);
|
||||
void account_balance ();
|
||||
void account_block_count ();
|
||||
|
|
@ -138,7 +138,7 @@ public:
|
|||
std::string body;
|
||||
nano::node & node;
|
||||
boost::property_tree::ptree request;
|
||||
std::function<void(std::string const &)> response;
|
||||
std::function<void (std::string const &)> response;
|
||||
void response_errors ();
|
||||
std::error_code ec;
|
||||
std::string action;
|
||||
|
|
@ -161,16 +161,16 @@ public:
|
|||
double multiplier_optional_impl (nano::work_version const, uint64_t &);
|
||||
nano::work_version work_version_optional_impl (nano::work_version const default_a);
|
||||
bool enable_sign_hash{ false };
|
||||
std::function<void()> stop_callback;
|
||||
std::function<void ()> stop_callback;
|
||||
nano::node_rpc_config const & node_rpc_config;
|
||||
std::function<void()> create_worker_task (std::function<void(std::shared_ptr<nano::json_handler> const &)> const &);
|
||||
std::function<void ()> create_worker_task (std::function<void (std::shared_ptr<nano::json_handler> const &)> const &);
|
||||
};
|
||||
|
||||
class inprocess_rpc_handler final : public nano::rpc_handler_interface
|
||||
{
|
||||
public:
|
||||
inprocess_rpc_handler (
|
||||
nano::node & node_a, nano::ipc::ipc_server & ipc_server_a, nano::node_rpc_config const & node_rpc_config_a, std::function<void()> stop_callback_a = []() {}) :
|
||||
nano::node & node_a, nano::ipc::ipc_server & ipc_server_a, nano::node_rpc_config const & node_rpc_config_a, std::function<void ()> stop_callback_a = [] () {}) :
|
||||
node (node_a),
|
||||
ipc_server (ipc_server_a),
|
||||
stop_callback (stop_callback_a),
|
||||
|
|
@ -178,8 +178,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void process_request (std::string const &, std::string const & body_a, std::function<void(std::string const &)> response_a) override;
|
||||
void process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body_a, std::function<void(std::shared_ptr<std::string> const &)> response_a) override;
|
||||
void process_request (std::string const &, std::string const & body_a, std::function<void (std::string const &)> response_a) override;
|
||||
void process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body_a, std::function<void (std::shared_ptr<std::string> const &)> response_a) override;
|
||||
|
||||
void stop () override
|
||||
{
|
||||
|
|
@ -198,7 +198,7 @@ private:
|
|||
nano::node & node;
|
||||
nano::ipc::ipc_server & ipc_server;
|
||||
boost::optional<nano::rpc &> rpc;
|
||||
std::function<void()> stop_callback;
|
||||
std::function<void ()> stop_callback;
|
||||
nano::node_rpc_config const & node_rpc_config;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ size_t mdb_val::size () const
|
|||
|
||||
template <>
|
||||
mdb_val::db_val (size_t size_a, void * data_a) :
|
||||
value ({ size_a, data_a })
|
||||
value ({ size_a, data_a })
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -41,10 +41,10 @@ void mdb_val::convert_buffer_to_value ()
|
|||
}
|
||||
|
||||
nano::mdb_store::mdb_store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade_a) :
|
||||
logger (logger_a),
|
||||
env (error, path_a, nano::mdb_env::options::make ().set_config (lmdb_config_a).set_use_no_mem_init (true)),
|
||||
mdb_txn_tracker (logger_a, txn_tracking_config_a, block_processor_batch_max_time_a),
|
||||
txn_tracking_enabled (txn_tracking_config_a.enable)
|
||||
logger (logger_a),
|
||||
env (error, path_a, nano::mdb_env::options::make ().set_config (lmdb_config_a).set_use_no_mem_init (true)),
|
||||
mdb_txn_tracker (logger_a, txn_tracking_config_a, block_processor_batch_max_time_a),
|
||||
txn_tracking_enabled (txn_tracking_config_a.enable)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
|
@ -176,10 +176,10 @@ nano::mdb_txn_callbacks nano::mdb_store::create_txn_callbacks () const
|
|||
nano::mdb_txn_callbacks mdb_txn_callbacks;
|
||||
if (txn_tracking_enabled)
|
||||
{
|
||||
mdb_txn_callbacks.txn_start = ([& mdb_txn_tracker = mdb_txn_tracker](const nano::transaction_impl * transaction_impl) {
|
||||
mdb_txn_callbacks.txn_start = ([&mdb_txn_tracker = mdb_txn_tracker] (const nano::transaction_impl * transaction_impl) {
|
||||
mdb_txn_tracker.add (transaction_impl);
|
||||
});
|
||||
mdb_txn_callbacks.txn_end = ([& mdb_txn_tracker = mdb_txn_tracker](const nano::transaction_impl * transaction_impl) {
|
||||
mdb_txn_callbacks.txn_end = ([&mdb_txn_tracker = mdb_txn_tracker] (const nano::transaction_impl * transaction_impl) {
|
||||
mdb_txn_tracker.erase (transaction_impl);
|
||||
});
|
||||
}
|
||||
|
|
@ -1181,8 +1181,8 @@ std::shared_ptr<nano::block> nano::mdb_store::block_get_v14 (nano::transaction c
|
|||
}
|
||||
|
||||
nano::mdb_store::upgrade_counters::upgrade_counters (uint64_t count_before_v0, uint64_t count_before_v1) :
|
||||
before_v0 (count_before_v0),
|
||||
before_v1 (count_before_v1)
|
||||
before_v0 (count_before_v0),
|
||||
before_v1 (count_before_v1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ private:
|
|||
}
|
||||
|
||||
nano::read_mdb_txn::read_mdb_txn (nano::mdb_env const & environment_a, nano::mdb_txn_callbacks txn_callbacks_a) :
|
||||
txn_callbacks (txn_callbacks_a)
|
||||
txn_callbacks (txn_callbacks_a)
|
||||
{
|
||||
auto status (mdb_txn_begin (environment_a, nullptr, MDB_RDONLY, &handle));
|
||||
release_assert (status == 0);
|
||||
|
|
@ -84,8 +84,8 @@ void * nano::read_mdb_txn::get_handle () const
|
|||
}
|
||||
|
||||
nano::write_mdb_txn::write_mdb_txn (nano::mdb_env const & environment_a, nano::mdb_txn_callbacks txn_callbacks_a) :
|
||||
env (environment_a),
|
||||
txn_callbacks (txn_callbacks_a)
|
||||
env (environment_a),
|
||||
txn_callbacks (txn_callbacks_a)
|
||||
{
|
||||
renew ();
|
||||
}
|
||||
|
|
@ -126,9 +126,9 @@ bool nano::write_mdb_txn::contains (nano::tables table_a) const
|
|||
}
|
||||
|
||||
nano::mdb_txn_tracker::mdb_txn_tracker (nano::logger_mt & logger_a, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a) :
|
||||
logger (logger_a),
|
||||
txn_tracking_config (txn_tracking_config_a),
|
||||
block_processor_batch_max_time (block_processor_batch_max_time_a)
|
||||
logger (logger_a),
|
||||
txn_tracking_config (txn_tracking_config_a),
|
||||
block_processor_batch_max_time (block_processor_batch_max_time_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ void nano::mdb_txn_tracker::serialize_json (boost::property_tree::ptree & json,
|
|||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
copy_stats = stats;
|
||||
are_writes.reserve (stats.size ());
|
||||
std::transform (stats.cbegin (), stats.cend (), std::back_inserter (are_writes), [](auto & mdb_txn_stat) {
|
||||
std::transform (stats.cbegin (), stats.cend (), std::back_inserter (are_writes), [] (auto & mdb_txn_stat) {
|
||||
return mdb_txn_stat.is_write ();
|
||||
});
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ void nano::mdb_txn_tracker::serialize_json (boost::property_tree::ptree & json,
|
|||
// Get the time difference now as creating stacktraces (Debug/Windows for instance) can take a while so results won't be as accurate
|
||||
std::vector<std::chrono::milliseconds> times_since_start;
|
||||
times_since_start.reserve (copy_stats.size ());
|
||||
std::transform (copy_stats.cbegin (), copy_stats.cend (), std::back_inserter (times_since_start), [](const auto & stat) {
|
||||
std::transform (copy_stats.cbegin (), copy_stats.cend (), std::back_inserter (times_since_start), [] (const auto & stat) {
|
||||
return stat.timer.since_start ();
|
||||
});
|
||||
debug_assert (times_since_start.size () == copy_stats.size ());
|
||||
|
|
@ -229,9 +229,9 @@ void nano::mdb_txn_tracker::erase (const nano::transaction_impl * transaction_im
|
|||
}
|
||||
|
||||
nano::mdb_txn_stats::mdb_txn_stats (const nano::transaction_impl * transaction_impl) :
|
||||
transaction_impl (transaction_impl),
|
||||
thread_name (nano::thread_role::get_string ()),
|
||||
stacktrace (std::make_shared<boost::stacktrace::stacktrace> ())
|
||||
transaction_impl (transaction_impl),
|
||||
thread_name (nano::thread_role::get_string ()),
|
||||
stacktrace (std::make_shared<boost::stacktrace::stacktrace> ())
|
||||
{
|
||||
timer.start ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ class mdb_env;
|
|||
class mdb_txn_callbacks
|
||||
{
|
||||
public:
|
||||
std::function<void(const nano::transaction_impl *)> txn_start{ [](const nano::transaction_impl *) {} };
|
||||
std::function<void(const nano::transaction_impl *)> txn_end{ [](const nano::transaction_impl *) {} };
|
||||
std::function<void (const nano::transaction_impl *)> txn_start{ [] (const nano::transaction_impl *) {} };
|
||||
std::function<void (const nano::transaction_impl *)> txn_end{ [] (const nano::transaction_impl *) {} };
|
||||
};
|
||||
|
||||
class read_mdb_txn final : public read_transaction_impl
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ nano::wallet_value::wallet_value (nano::db_val<MDB_val> const & val_a)
|
|||
}
|
||||
|
||||
nano::wallet_value::wallet_value (nano::raw_key const & key_a, uint64_t work_a) :
|
||||
key (key_a),
|
||||
work (work_a)
|
||||
key (key_a),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,24 +12,24 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::network::network (nano::node & node_a, uint16_t port_a) :
|
||||
syn_cookies (node_a.network_params.node.max_peers_per_ip),
|
||||
buffer_container (node_a.stats, nano::network::buffer_size, 4096), // 2Mb receive buffer
|
||||
resolver (node_a.io_ctx),
|
||||
limiter (node_a.config.bandwidth_limit_burst_ratio, node_a.config.bandwidth_limit),
|
||||
tcp_message_manager (node_a.config.tcp_incoming_connections_max),
|
||||
node (node_a),
|
||||
publish_filter (256 * 1024),
|
||||
udp_channels (node_a, port_a),
|
||||
tcp_channels (node_a),
|
||||
port (port_a),
|
||||
disconnect_observer ([]() {})
|
||||
syn_cookies (node_a.network_params.node.max_peers_per_ip),
|
||||
buffer_container (node_a.stats, nano::network::buffer_size, 4096), // 2Mb receive buffer
|
||||
resolver (node_a.io_ctx),
|
||||
limiter (node_a.config.bandwidth_limit_burst_ratio, node_a.config.bandwidth_limit),
|
||||
tcp_message_manager (node_a.config.tcp_incoming_connections_max),
|
||||
node (node_a),
|
||||
publish_filter (256 * 1024),
|
||||
udp_channels (node_a, port_a),
|
||||
tcp_channels (node_a),
|
||||
port (port_a),
|
||||
disconnect_observer ([] () {})
|
||||
{
|
||||
boost::thread::attributes attrs;
|
||||
nano::thread_attributes::set (attrs);
|
||||
// UDP
|
||||
for (size_t i = 0; i < node.config.network_threads && !node.flags.disable_udp; ++i)
|
||||
{
|
||||
packet_processing_threads.emplace_back (attrs, [this]() {
|
||||
packet_processing_threads.emplace_back (attrs, [this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::packet_processing);
|
||||
try
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ disconnect_observer ([]() {})
|
|||
// TCP
|
||||
for (size_t i = 0; i < node.config.network_threads && !node.flags.disable_tcp_realtime; ++i)
|
||||
{
|
||||
packet_processing_threads.emplace_back (attrs, [this]() {
|
||||
packet_processing_threads.emplace_back (attrs, [this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::packet_processing);
|
||||
try
|
||||
{
|
||||
|
|
@ -211,7 +211,7 @@ void nano::network::flood_vote_pr (std::shared_ptr<nano::vote> const & vote_a)
|
|||
}
|
||||
}
|
||||
|
||||
void nano::network::flood_block_many (std::deque<std::shared_ptr<nano::block>> blocks_a, std::function<void()> callback_a, unsigned delay_a)
|
||||
void nano::network::flood_block_many (std::deque<std::shared_ptr<nano::block>> blocks_a, std::function<void ()> callback_a, unsigned delay_a)
|
||||
{
|
||||
if (!blocks_a.empty ())
|
||||
{
|
||||
|
|
@ -221,7 +221,7 @@ void nano::network::flood_block_many (std::deque<std::shared_ptr<nano::block>> b
|
|||
if (!blocks_a.empty ())
|
||||
{
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a + std::rand () % delay_a), [node_w, blocks (std::move (blocks_a)), callback_a, delay_a]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a + std::rand () % delay_a), [node_w, blocks (std::move (blocks_a)), callback_a, delay_a] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.flood_block_many (std::move (blocks), callback_a, delay_a);
|
||||
|
|
@ -290,7 +290,7 @@ void nano::network::broadcast_confirm_req_base (std::shared_ptr<nano::block> con
|
|||
delay_a += std::rand () % broadcast_interval_ms;
|
||||
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a), [node_w, block_a, endpoints_a, delay_a]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a), [node_w, block_a, endpoints_a, delay_a] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.broadcast_confirm_req_base (block_a, endpoints_a, delay_a, true);
|
||||
|
|
@ -299,7 +299,7 @@ void nano::network::broadcast_confirm_req_base (std::shared_ptr<nano::block> con
|
|||
}
|
||||
}
|
||||
|
||||
void nano::network::broadcast_confirm_req_batched_many (std::unordered_map<std::shared_ptr<nano::transport::channel>, std::deque<std::pair<nano::block_hash, nano::root>>> request_bundle_a, std::function<void()> callback_a, unsigned delay_a, bool resumption_a)
|
||||
void nano::network::broadcast_confirm_req_batched_many (std::unordered_map<std::shared_ptr<nano::transport::channel>, std::deque<std::pair<nano::block_hash, nano::root>>> request_bundle_a, std::function<void ()> callback_a, unsigned delay_a, bool resumption_a)
|
||||
{
|
||||
if (!resumption_a && node.config.logging.network_logging ())
|
||||
{
|
||||
|
|
@ -330,7 +330,7 @@ void nano::network::broadcast_confirm_req_batched_many (std::unordered_map<std::
|
|||
if (!request_bundle_a.empty ())
|
||||
{
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a), [node_w, request_bundle_a, callback_a, delay_a]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a), [node_w, request_bundle_a, callback_a, delay_a] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.broadcast_confirm_req_batched_many (request_bundle_a, callback_a, delay_a, true);
|
||||
|
|
@ -343,7 +343,7 @@ void nano::network::broadcast_confirm_req_batched_many (std::unordered_map<std::
|
|||
}
|
||||
}
|
||||
|
||||
void nano::network::broadcast_confirm_req_many (std::deque<std::pair<std::shared_ptr<nano::block>, std::shared_ptr<std::vector<std::shared_ptr<nano::transport::channel>>>>> requests_a, std::function<void()> callback_a, unsigned delay_a)
|
||||
void nano::network::broadcast_confirm_req_many (std::deque<std::pair<std::shared_ptr<nano::block>, std::shared_ptr<std::vector<std::shared_ptr<nano::transport::channel>>>>> requests_a, std::function<void ()> callback_a, unsigned delay_a)
|
||||
{
|
||||
auto pair_l (requests_a.front ());
|
||||
requests_a.pop_front ();
|
||||
|
|
@ -359,7 +359,7 @@ void nano::network::broadcast_confirm_req_many (std::deque<std::pair<std::shared
|
|||
if (!requests_a.empty ())
|
||||
{
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a + std::rand () % delay_a), [node_w, requests_a, callback_a, delay_a]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (delay_a + std::rand () % delay_a), [node_w, requests_a, callback_a, delay_a] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.broadcast_confirm_req_many (requests_a, callback_a, delay_a);
|
||||
|
|
@ -547,7 +547,7 @@ void nano::network::merge_peer (nano::endpoint const & peer_a)
|
|||
if (!reachout (peer_a, node.config.allow_local_peers))
|
||||
{
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.network.tcp_channels.start_tcp (peer_a, [node_w](std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
node.network.tcp_channels.start_tcp (peer_a, [node_w] (std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.send_keepalive (channel_a);
|
||||
|
|
@ -605,7 +605,7 @@ std::deque<std::shared_ptr<nano::transport::channel>> nano::network::list_non_pr
|
|||
tcp_channels.list (result);
|
||||
udp_channels.list (result);
|
||||
nano::random_pool_shuffle (result.begin (), result.end ());
|
||||
result.erase (std::remove_if (result.begin (), result.end (), [this](std::shared_ptr<nano::transport::channel> const & channel) {
|
||||
result.erase (std::remove_if (result.begin (), result.end (), [this] (std::shared_ptr<nano::transport::channel> const & channel) {
|
||||
return this->node.rep_crawler.is_pr (*channel);
|
||||
}),
|
||||
result.end ());
|
||||
|
|
@ -733,7 +733,7 @@ void nano::network::ongoing_cleanup ()
|
|||
{
|
||||
cleanup (std::chrono::steady_clock::now () - node.network_params.node.cutoff);
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.node.period, [node_w]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.node.period, [node_w] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.ongoing_cleanup ();
|
||||
|
|
@ -745,7 +745,7 @@ void nano::network::ongoing_syn_cookie_cleanup ()
|
|||
{
|
||||
syn_cookies.purge (std::chrono::steady_clock::now () - nano::transport::syn_cookie_cutoff);
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + (nano::transport::syn_cookie_cutoff * 2), [node_w]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + (nano::transport::syn_cookie_cutoff * 2), [node_w] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.ongoing_syn_cookie_cleanup ();
|
||||
|
|
@ -758,7 +758,7 @@ void nano::network::ongoing_keepalive ()
|
|||
flood_keepalive (0.75f);
|
||||
flood_keepalive_self (0.25f);
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.node.half_period, [node_w]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.node.half_period, [node_w] () {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.ongoing_keepalive ();
|
||||
|
|
@ -796,12 +796,12 @@ void nano::network::erase (nano::transport::channel const & channel_a)
|
|||
}
|
||||
|
||||
nano::message_buffer_manager::message_buffer_manager (nano::stat & stats_a, size_t size, size_t count) :
|
||||
stats (stats_a),
|
||||
free (count),
|
||||
full (count),
|
||||
slab (size * count),
|
||||
entries (count),
|
||||
stopped (false)
|
||||
stats (stats_a),
|
||||
free (count),
|
||||
full (count),
|
||||
slab (size * count),
|
||||
entries (count),
|
||||
stopped (false)
|
||||
{
|
||||
debug_assert (count > 0);
|
||||
debug_assert (size > 0);
|
||||
|
|
@ -820,7 +820,7 @@ nano::message_buffer * nano::message_buffer_manager::allocate ()
|
|||
if (!stopped && free.empty () && full.empty ())
|
||||
{
|
||||
stats.inc (nano::stat::type::udp, nano::stat::detail::blocking, nano::stat::dir::in);
|
||||
condition.wait (lock, [& stopped = stopped, &free = free, &full = full] { return stopped || !free.empty () || !full.empty (); });
|
||||
condition.wait (lock, [&stopped = stopped, &free = free, &full = full] { return stopped || !free.empty () || !full.empty (); });
|
||||
}
|
||||
nano::message_buffer * result (nullptr);
|
||||
if (!free.empty ())
|
||||
|
|
@ -884,7 +884,7 @@ void nano::message_buffer_manager::stop ()
|
|||
}
|
||||
|
||||
nano::tcp_message_manager::tcp_message_manager (unsigned incoming_connections_max_a) :
|
||||
max_entries (incoming_connections_max_a * nano::tcp_message_manager::max_entries_per_connection + 1)
|
||||
max_entries (incoming_connections_max_a * nano::tcp_message_manager::max_entries_per_connection + 1)
|
||||
{
|
||||
debug_assert (max_entries > 0);
|
||||
}
|
||||
|
|
@ -935,7 +935,7 @@ void nano::tcp_message_manager::stop ()
|
|||
}
|
||||
|
||||
nano::syn_cookies::syn_cookies (size_t max_cookies_per_ip_a) :
|
||||
max_cookies_per_ip (max_cookies_per_ip_a)
|
||||
max_cookies_per_ip (max_cookies_per_ip_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public:
|
|||
void flood_block_initial (std::shared_ptr<nano::block> const &);
|
||||
// Flood block to a random selection of peers
|
||||
void flood_block (std::shared_ptr<nano::block> const &, nano::buffer_drop_policy const = nano::buffer_drop_policy::limiter);
|
||||
void flood_block_many (std::deque<std::shared_ptr<nano::block>>, std::function<void()> = nullptr, unsigned = broadcast_interval_ms);
|
||||
void flood_block_many (std::deque<std::shared_ptr<nano::block>>, std::function<void ()> = nullptr, unsigned = broadcast_interval_ms);
|
||||
void merge_peers (std::array<nano::endpoint, 8> const &);
|
||||
void merge_peer (nano::endpoint const &);
|
||||
void send_keepalive (std::shared_ptr<nano::transport::channel> const &);
|
||||
|
|
@ -150,8 +150,8 @@ public:
|
|||
void send_confirm_req (std::shared_ptr<nano::transport::channel> const & channel_a, std::pair<nano::block_hash, nano::block_hash> const & hash_root_a);
|
||||
void broadcast_confirm_req (std::shared_ptr<nano::block> const &);
|
||||
void broadcast_confirm_req_base (std::shared_ptr<nano::block> const &, std::shared_ptr<std::vector<std::shared_ptr<nano::transport::channel>>> const &, unsigned, bool = false);
|
||||
void broadcast_confirm_req_batched_many (std::unordered_map<std::shared_ptr<nano::transport::channel>, std::deque<std::pair<nano::block_hash, nano::root>>>, std::function<void()> = nullptr, unsigned = broadcast_interval_ms, bool = false);
|
||||
void broadcast_confirm_req_many (std::deque<std::pair<std::shared_ptr<nano::block>, std::shared_ptr<std::vector<std::shared_ptr<nano::transport::channel>>>>>, std::function<void()> = nullptr, unsigned = broadcast_interval_ms);
|
||||
void broadcast_confirm_req_batched_many (std::unordered_map<std::shared_ptr<nano::transport::channel>, std::deque<std::pair<nano::block_hash, nano::root>>>, std::function<void ()> = nullptr, unsigned = broadcast_interval_ms, bool = false);
|
||||
void broadcast_confirm_req_many (std::deque<std::pair<std::shared_ptr<nano::block>, std::shared_ptr<std::vector<std::shared_ptr<nano::transport::channel>>>>>, std::function<void ()> = nullptr, unsigned = broadcast_interval_ms);
|
||||
std::shared_ptr<nano::transport::channel> find_node_id (nano::account const &);
|
||||
std::shared_ptr<nano::transport::channel> find_channel (nano::endpoint const &);
|
||||
void process_message (nano::message const &, std::shared_ptr<nano::transport::channel> const &);
|
||||
|
|
@ -190,9 +190,9 @@ public:
|
|||
nano::transport::udp_channels udp_channels;
|
||||
nano::transport::tcp_channels tcp_channels;
|
||||
std::atomic<uint16_t> port{ 0 };
|
||||
std::function<void()> disconnect_observer;
|
||||
std::function<void ()> disconnect_observer;
|
||||
// Called when a new channel is observed
|
||||
std::function<void(std::shared_ptr<nano::transport::channel>)> channel_observer;
|
||||
std::function<void (std::shared_ptr<nano::transport::channel>)> channel_observer;
|
||||
std::atomic<bool> stopped{ false };
|
||||
static unsigned const broadcast_interval_ms = 10;
|
||||
static size_t const buffer_size = 512;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue