remove clang-format guards as not needed on 8 (#2492)
This commit is contained in:
parent
d5ab41e397
commit
baafd5ffc2
30 changed files with 59 additions and 176 deletions
|
@ -152,13 +152,11 @@ TEST (active_transactions, adjusted_difficulty_overflow_max)
|
|||
auto send2_root (node1.active.roots.find (send2->qualified_root ()));
|
||||
auto open1_root (node1.active.roots.find (open1->qualified_root ()));
|
||||
auto open2_root (node1.active.roots.find (open2->qualified_root ()));
|
||||
// clang-format off
|
||||
auto modify_difficulty = [& roots = node1.active.roots](auto & existing_root) {
|
||||
roots.modify (existing_root, [](nano::conflict_info & info_a) {
|
||||
info_a.difficulty = std::numeric_limits<std::uint64_t>::max ();
|
||||
});
|
||||
};
|
||||
// clang-format on
|
||||
modify_difficulty (send1_root);
|
||||
modify_difficulty (send2_root);
|
||||
modify_difficulty (open1_root);
|
||||
|
@ -207,13 +205,11 @@ TEST (active_transactions, adjusted_difficulty_overflow_min)
|
|||
auto open1_root (node1.active.roots.find (open1->qualified_root ()));
|
||||
auto open2_root (node1.active.roots.find (open2->qualified_root ()));
|
||||
auto send3_root (node1.active.roots.find (send3->qualified_root ()));
|
||||
// clang-format off
|
||||
auto modify_difficulty = [& roots = node1.active.roots](auto & existing_root) {
|
||||
roots.modify (existing_root, [](nano::conflict_info & info_a) {
|
||||
info_a.difficulty = std::numeric_limits<std::uint64_t>::min () + 1;
|
||||
});
|
||||
};
|
||||
// clang-format on
|
||||
modify_difficulty (send1_root);
|
||||
modify_difficulty (send2_root);
|
||||
modify_difficulty (open1_root);
|
||||
|
|
|
@ -1773,7 +1773,6 @@ TEST (mdb_block_store, upgrade_v16_v17)
|
|||
nano::state_block block2 (nano::test_genesis_key.pub, block1.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio - 1, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (block1.hash ()));
|
||||
nano::state_block block3 (nano::test_genesis_key.pub, block2.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio - 2, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (block2.hash ()));
|
||||
|
||||
// clang-format off
|
||||
auto code = [block1, block2, block3](auto confirmation_height, nano::block_hash const & expected_cemented_frontier) {
|
||||
auto path (nano::unique_path ());
|
||||
nano::mdb_val value;
|
||||
|
@ -1811,7 +1810,6 @@ TEST (mdb_block_store, upgrade_v16_v17)
|
|||
// Version should be correct
|
||||
ASSERT_LT (16, store.version_get (transaction));
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
code (0, nano::block_hash (0));
|
||||
code (1, genesis.hash ());
|
||||
|
@ -1827,7 +1825,6 @@ TEST (mdb_block_store, upgrade_backup)
|
|||
fs::create_directory (dir);
|
||||
auto path = dir / "data.ldb";
|
||||
/** Returns 'dir' if backup file cannot be found */
|
||||
// clang-format off
|
||||
auto get_backup_path = [&dir]() {
|
||||
for (fs::directory_iterator itr (dir); itr != fs::directory_iterator (); ++itr)
|
||||
{
|
||||
|
@ -1838,7 +1835,6 @@ TEST (mdb_block_store, upgrade_backup)
|
|||
}
|
||||
return dir;
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
|
|
|
@ -843,13 +843,11 @@ TEST (confirmation_height, prioritize_frontiers)
|
|||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
constexpr auto num_accounts = 5;
|
||||
// clang-format off
|
||||
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);
|
||||
});
|
||||
};
|
||||
// clang-format on
|
||||
{
|
||||
node->active.prioritize_frontiers_for_confirmation (transaction, std::chrono::seconds (1), std::chrono::seconds (1));
|
||||
ASSERT_EQ (node->active.priority_cementable_frontiers_size (), num_accounts);
|
||||
|
|
|
@ -1058,7 +1058,6 @@ TEST (json, backup)
|
|||
ASSERT_EQ ("created", object1.text);
|
||||
|
||||
/** Returns 'dir' if backup file cannot be found */
|
||||
// clang-format off
|
||||
auto get_backup_path = [&dir]() {
|
||||
for (fs::directory_iterator itr (dir); itr != fs::directory_iterator (); ++itr)
|
||||
{
|
||||
|
@ -1073,7 +1072,6 @@ TEST (json, backup)
|
|||
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));
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// There should only be the original file in this directory
|
||||
ASSERT_EQ (get_file_count (), 1);
|
||||
|
@ -3264,7 +3262,6 @@ TEST (node, dont_write_lock_node)
|
|||
|
||||
std::promise<void> write_lock_held_promise;
|
||||
std::promise<void> finished_promise;
|
||||
// clang-format off
|
||||
std::thread ([&path, &write_lock_held_promise, &finished_promise]() {
|
||||
nano::logger_mt logger;
|
||||
auto store = nano::make_store (logger, path, false, true);
|
||||
|
@ -3281,7 +3278,6 @@ TEST (node, dont_write_lock_node)
|
|||
finished_promise.get_future ().wait ();
|
||||
})
|
||||
.detach ();
|
||||
// clang-format off
|
||||
|
||||
write_lock_held_promise.get_future ().wait ();
|
||||
|
||||
|
@ -3366,7 +3362,7 @@ TEST (node, bandwidth_limiter)
|
|||
nano::system system;
|
||||
nano::genesis genesis;
|
||||
nano::publish message (genesis.open);
|
||||
auto message_size = message.to_bytes ()->size();
|
||||
auto message_size = message.to_bytes ()->size ();
|
||||
auto message_limit = 4; // must be multiple of the number of channels
|
||||
nano::node_config node_config (24000, system.logging);
|
||||
node_config.bandwidth_limit = message_limit * message_size;
|
||||
|
@ -3374,7 +3370,7 @@ TEST (node, bandwidth_limiter)
|
|||
auto channel1 (node.network.udp_channels.create (node.network.endpoint ()));
|
||||
auto channel2 (node.network.udp_channels.create (node.network.endpoint ()));
|
||||
auto start (std::chrono::steady_clock::now ());
|
||||
for (unsigned i=0; i < message_limit; i+=2) // number of channels
|
||||
for (unsigned i = 0; i < message_limit; i += 2) // number of channels
|
||||
{
|
||||
channel1->send (message);
|
||||
channel2->send (message);
|
||||
|
|
|
@ -893,7 +893,6 @@ TEST (wallet, upgrade_backup)
|
|||
namespace fs = boost::filesystem;
|
||||
fs::create_directory (dir);
|
||||
/** Returns 'dir' if backup file cannot be found */
|
||||
// clang-format off
|
||||
auto get_backup_path = [&dir]() {
|
||||
for (fs::directory_iterator itr (dir); itr != fs::directory_iterator (); ++itr)
|
||||
{
|
||||
|
@ -904,7 +903,6 @@ TEST (wallet, upgrade_backup)
|
|||
}
|
||||
return dir;
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
auto wallet_id = nano::random_wallet_id ();
|
||||
{
|
||||
|
|
|
@ -227,7 +227,6 @@ std::string nano::ipc::request (nano::ipc::ipc_client & ipc_client, std::string
|
|||
auto res (std::make_shared<std::vector<uint8_t>> ());
|
||||
|
||||
std::promise<std::string> result_l;
|
||||
// clang-format off
|
||||
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) {
|
||||
|
@ -238,7 +237,6 @@ std::string nano::ipc::request (nano::ipc::ipc_client & ipc_client, std::string
|
|||
});
|
||||
});
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
return result_l.get_future ().get ();
|
||||
}
|
||||
|
|
|
@ -225,12 +225,11 @@ boost::optional<uint64_t> nano::work_pool::generate (nano::root const & root_a,
|
|||
{
|
||||
std::promise<boost::optional<uint64_t>> work;
|
||||
std::future<boost::optional<uint64_t>> future = work.get_future ();
|
||||
// clang-format off
|
||||
generate (root_a, [&work](boost::optional<uint64_t> work_a) {
|
||||
generate (
|
||||
root_a, [&work](boost::optional<uint64_t> work_a) {
|
||||
work.set_value (work_a);
|
||||
},
|
||||
difficulty_a);
|
||||
// clang-format on
|
||||
result = future.get ().value ();
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -123,13 +123,11 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
rpc_process = std::make_unique<boost::process::child> (config.rpc.child_process.rpc_path, "--daemon", "--data_path", data_path, "--network", network);
|
||||
#else
|
||||
auto rpc_exe_command = boost::str (boost::format ("%1% --daemon --data_path=%2% --network=%3%") % config.rpc.child_process.rpc_path % data_path % network);
|
||||
// clang-format off
|
||||
rpc_process_thread = std::make_unique<std::thread> ([rpc_exe_command, &logger = node->logger]() {
|
||||
nano::thread_role::set (nano::thread_role::name::rpc_process_container);
|
||||
std::system (rpc_exe_command.c_str ());
|
||||
logger.always_log ("RPC server has stopped");
|
||||
});
|
||||
// clang-format on
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1277,12 +1277,10 @@ int main (int argc, char * const * argv)
|
|||
{
|
||||
nano::pending_key const & key (i->first);
|
||||
nano::pending_info const & info (i->second);
|
||||
// clang-format off
|
||||
auto & account = key.account;
|
||||
auto exists = std::any_of (opened_account_versions.begin (), opened_account_versions.end (), [&account](auto const & account_version) {
|
||||
return account_version.find (account) != account_version.end ();
|
||||
});
|
||||
// clang-format on
|
||||
if (!exists)
|
||||
{
|
||||
// This is an unopened account, store the highest pending version
|
||||
|
|
|
@ -22,12 +22,10 @@ election_time_to_live (node_a.network_params.network.is_test_network () ? 0s : 1
|
|||
min_time_between_requests (node_a.network_params.network.is_test_network () ? 25ms : 3s),
|
||||
min_time_between_floods (node_a.network_params.network.is_test_network () ? 50ms : 6s),
|
||||
min_request_count_flood (node_a.network_params.network.is_test_network () ? 0 : 2),
|
||||
// clang-format off
|
||||
thread ([this]() {
|
||||
nano::thread_role::set (nano::thread_role::name::request_loop);
|
||||
request_loop ();
|
||||
})
|
||||
// clang-format on
|
||||
{
|
||||
assert (min_time_between_requests > std::chrono::milliseconds (node.network_params.network.request_interval_ms));
|
||||
assert (min_time_between_floods > std::chrono::milliseconds (node.network_params.network.request_interval_ms));
|
||||
|
@ -339,9 +337,7 @@ void nano::active_transactions::request_loop ()
|
|||
// Sleep until all broadcasts are done, plus the remaining loop time
|
||||
if (!stopped)
|
||||
{
|
||||
// clang-format off
|
||||
condition.wait_until (lock, wakeup_l, [&wakeup_l, &stopped = stopped] { return stopped || std::chrono::steady_clock::now () >= wakeup_l; });
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,9 +317,7 @@ void nano::bootstrap_attempt::run ()
|
|||
|
||||
std::shared_ptr<nano::bootstrap_client> nano::bootstrap_attempt::connection (nano::unique_lock<std::mutex> & lock_a, bool use_front_connection)
|
||||
{
|
||||
// clang-format off
|
||||
condition.wait (lock_a, [& stopped = stopped, &idle = idle] { return stopped || !idle.empty (); });
|
||||
// clang-format on
|
||||
std::shared_ptr<nano::bootstrap_client> result;
|
||||
if (!idle.empty ())
|
||||
{
|
||||
|
@ -686,9 +684,7 @@ bool nano::bootstrap_attempt::confirm_frontiers (nano::unique_lock<std::mutex> &
|
|||
{
|
||||
bool confirmed (false);
|
||||
assert (!frontiers_confirmed);
|
||||
// clang-format off
|
||||
condition.wait (lock_a, [& stopped = stopped] { return !stopped; });
|
||||
// clang-format on
|
||||
std::vector<nano::block_hash> frontiers;
|
||||
for (auto i (pulls.begin ()), end (pulls.end ()); i != end && frontiers.size () != nano::bootstrap_limits::bootstrap_max_confirm_frontiers; ++i)
|
||||
{
|
||||
|
@ -1381,9 +1377,7 @@ void nano::bootstrap_initiator::bootstrap (bool force, std::string id_a)
|
|||
if (force && attempt != nullptr)
|
||||
{
|
||||
attempt->stop ();
|
||||
// clang-format off
|
||||
condition.wait (lock, [&attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
// clang-format on
|
||||
condition.wait (lock, [& attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
}
|
||||
if (!stopped && attempt == nullptr)
|
||||
{
|
||||
|
@ -1405,9 +1399,7 @@ void nano::bootstrap_initiator::bootstrap (nano::endpoint const & endpoint_a, bo
|
|||
if (attempt != nullptr)
|
||||
{
|
||||
attempt->stop ();
|
||||
// clang-format off
|
||||
condition.wait (lock, [&attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
// clang-format on
|
||||
condition.wait (lock, [& attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
}
|
||||
node.stats.inc (nano::stat::type::bootstrap, nano::stat::detail::initiate, nano::stat::dir::out);
|
||||
attempt = std::make_shared<nano::bootstrap_attempt> (node.shared (), nano::bootstrap_mode::legacy, id_a);
|
||||
|
@ -1431,9 +1423,7 @@ void nano::bootstrap_initiator::bootstrap_lazy (nano::hash_or_account const & ha
|
|||
if (force && attempt != nullptr)
|
||||
{
|
||||
attempt->stop ();
|
||||
// clang-format off
|
||||
condition.wait (lock, [&attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
// clang-format on
|
||||
condition.wait (lock, [& attempt = attempt, &stopped = stopped] { return stopped || attempt == nullptr; });
|
||||
}
|
||||
node.stats.inc (nano::stat::type::bootstrap, nano::stat::detail::initiate_lazy, nano::stat::dir::out);
|
||||
if (attempt == nullptr)
|
||||
|
|
|
@ -577,8 +577,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 ();
|
||||
// clang-format off
|
||||
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)
|
||||
|
@ -597,7 +596,6 @@ public:
|
|||
}
|
||||
}
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
else if (message_a.response)
|
||||
{
|
||||
|
|
|
@ -369,9 +369,8 @@ void nano::distributed_work::handle_failure (bool const last_a)
|
|||
auto now (std::chrono::steady_clock::now ());
|
||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
auto next_backoff (std::min (backoff * 2, std::chrono::seconds (5 * 60)));
|
||||
// clang-format off
|
||||
node.alarm.add (now + std::chrono::seconds (backoff), [ node_w, request_l = request, next_backoff] {
|
||||
bool error_l {true};
|
||||
node.alarm.add (now + std::chrono::seconds (backoff), [node_w, request_l = request, next_backoff] {
|
||||
bool error_l{ true };
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
error_l = node_l->distributed_work.make (next_backoff, request_l);
|
||||
|
@ -381,7 +380,6 @@ void nano::distributed_work::handle_failure (bool const last_a)
|
|||
request_l.callback (boost::none);
|
||||
}
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -677,9 +677,7 @@ void nano::json_handler::account_representative ()
|
|||
void nano::json_handler::account_representative_set ()
|
||||
{
|
||||
auto rpc_l (shared_from_this ());
|
||||
// clang-format off
|
||||
node.worker.push_task ([ rpc_l, work_generation_enabled = node.work_generation_enabled () ]() {
|
||||
// clang-format on
|
||||
node.worker.push_task ([rpc_l, work_generation_enabled = node.work_generation_enabled ()]() {
|
||||
auto wallet (rpc_l->wallet_impl ());
|
||||
auto account (rpc_l->account_impl ());
|
||||
std::string representative_text (rpc_l->request.get<std::string> ("representative"));
|
||||
|
@ -717,22 +715,21 @@ void nano::json_handler::account_representative_set ()
|
|||
bool generate_work (work == 0); // Disable work generation if "work" option is provided
|
||||
auto response_a (rpc_l->response);
|
||||
auto response_data (std::make_shared<boost::property_tree::ptree> (rpc_l->response_l));
|
||||
// clang-format off
|
||||
wallet->change_async(account, representative, [response_a, response_data](std::shared_ptr<nano::block> block) {
|
||||
wallet->change_async (
|
||||
account, representative, [response_a, response_data](std::shared_ptr<nano::block> block) {
|
||||
if (block != nullptr)
|
||||
{
|
||||
response_data->put("block", block->hash().to_string());
|
||||
response_data->put ("block", block->hash ().to_string ());
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json(ostream, *response_data);
|
||||
response_a(ostream.str());
|
||||
boost::property_tree::write_json (ostream, *response_data);
|
||||
response_a (ostream.str ());
|
||||
}
|
||||
else
|
||||
{
|
||||
json_error_response(response_a, "Error generating block");
|
||||
json_error_response (response_a, "Error generating block");
|
||||
}
|
||||
},
|
||||
work, generate_work);
|
||||
// clang-format on
|
||||
work, generate_work);
|
||||
}
|
||||
}
|
||||
// Because of change_async
|
||||
|
@ -3367,23 +3364,22 @@ void nano::json_handler::receive ()
|
|||
nano::account representative (wallet->store.representative (wallet_transaction));
|
||||
bool generate_work (work == 0); // Disable work generation if "work" option is provided
|
||||
auto response_a (response);
|
||||
// clang-format off
|
||||
wallet->receive_async(std::move(block), representative, node.network_params.ledger.genesis_amount, [response_a](std::shared_ptr<nano::block> block_a) {
|
||||
wallet->receive_async (
|
||||
std::move (block), representative, node.network_params.ledger.genesis_amount, [response_a](std::shared_ptr<nano::block> block_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put("block", block_a->hash().to_string());
|
||||
response_l.put ("block", block_a->hash ().to_string ());
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json(ostream, response_l);
|
||||
response_a(ostream.str());
|
||||
boost::property_tree::write_json (ostream, response_l);
|
||||
response_a (ostream.str ());
|
||||
}
|
||||
else
|
||||
{
|
||||
json_error_response(response_a, "Error generating block");
|
||||
json_error_response (response_a, "Error generating block");
|
||||
}
|
||||
},
|
||||
work, generate_work);
|
||||
// clang-format on
|
||||
work, generate_work);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3704,30 +3700,29 @@ void nano::json_handler::send ()
|
|||
boost::optional<std::string> send_id (request.get_optional<std::string> ("id"));
|
||||
auto response_a (response);
|
||||
auto response_data (std::make_shared<boost::property_tree::ptree> (response_l));
|
||||
// clang-format off
|
||||
wallet->send_async(source, destination, amount.number(), [balance, amount, response_a, response_data](std::shared_ptr<nano::block> block_a) {
|
||||
wallet->send_async (
|
||||
source, destination, amount.number (), [balance, amount, response_a, response_data](std::shared_ptr<nano::block> block_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
response_data->put("block", block_a->hash().to_string());
|
||||
response_data->put ("block", block_a->hash ().to_string ());
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json(ostream, *response_data);
|
||||
response_a(ostream.str());
|
||||
boost::property_tree::write_json (ostream, *response_data);
|
||||
response_a (ostream.str ());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (balance >= amount.number())
|
||||
if (balance >= amount.number ())
|
||||
{
|
||||
json_error_response(response_a, "Error generating block");
|
||||
json_error_response (response_a, "Error generating block");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::error_code ec(nano::error_common::insufficient_balance);
|
||||
json_error_response(response_a, ec.message());
|
||||
std::error_code ec (nano::error_common::insufficient_balance);
|
||||
json_error_response (response_a, ec.message ());
|
||||
}
|
||||
}
|
||||
},
|
||||
work, generate_work, send_id);
|
||||
// clang-format on
|
||||
work, generate_work, send_id);
|
||||
}
|
||||
}
|
||||
// Because of send_async
|
||||
|
@ -4656,9 +4651,8 @@ void nano::json_handler::wallet_representative_set ()
|
|||
}
|
||||
for (auto & account : accounts)
|
||||
{
|
||||
// clang-format off
|
||||
wallet->change_async(account, representative, [](std::shared_ptr<nano::block>) {}, 0, false);
|
||||
// clang-format on
|
||||
wallet->change_async (
|
||||
account, representative, [](std::shared_ptr<nano::block>) {}, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,14 +159,12 @@ nano::mdb_txn_callbacks nano::mdb_store::create_txn_callbacks ()
|
|||
nano::mdb_txn_callbacks mdb_txn_callbacks;
|
||||
if (txn_tracking_enabled)
|
||||
{
|
||||
// clang-format off
|
||||
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);
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
return mdb_txn_callbacks;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ public:
|
|||
void init (bool &, boost::filesystem::path const &, int max_dbs, bool use_no_mem_init, size_t map_size = 128ULL * 1024 * 1024 * 1024);
|
||||
~mdb_env ();
|
||||
operator MDB_env * () const;
|
||||
// clang-format off
|
||||
nano::read_transaction tx_begin_read (mdb_txn_callbacks txn_callbacks = mdb_txn_callbacks{}) const;
|
||||
nano::write_transaction tx_begin_write (mdb_txn_callbacks txn_callbacks = mdb_txn_callbacks{}) const;
|
||||
MDB_txn * tx (nano::transaction const & transaction_a) const;
|
||||
// clang-format on
|
||||
MDB_env * environment;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -139,11 +139,9 @@ 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 ());
|
||||
// clang-format off
|
||||
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 ();
|
||||
});
|
||||
// clang-format on
|
||||
assert (times_since_start.size () == copy_stats.size ());
|
||||
|
||||
for (size_t i = 0; i < times_since_start.size (); ++i)
|
||||
|
@ -202,9 +200,7 @@ void nano::mdb_txn_tracker::output_finished (nano::mdb_txn_stats const & mdb_txn
|
|||
void nano::mdb_txn_tracker::add (const nano::transaction_impl * transaction_impl)
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (mutex);
|
||||
// clang-format off
|
||||
assert (std::find_if (stats.cbegin (), stats.cend (), matches_txn (transaction_impl)) == stats.cend ());
|
||||
// clang-format on
|
||||
stats.emplace_back (transaction_impl);
|
||||
}
|
||||
|
||||
|
@ -212,9 +208,7 @@ void nano::mdb_txn_tracker::add (const nano::transaction_impl * transaction_impl
|
|||
void nano::mdb_txn_tracker::erase (const nano::transaction_impl * transaction_impl)
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (mutex);
|
||||
// clang-format off
|
||||
auto it = std::find_if (stats.begin (), stats.end (), matches_txn (transaction_impl));
|
||||
// clang-format on
|
||||
if (it != stats.end ())
|
||||
{
|
||||
output_finished (*it);
|
||||
|
|
|
@ -20,10 +20,8 @@ class mdb_env;
|
|||
class mdb_txn_callbacks
|
||||
{
|
||||
public:
|
||||
// clang-format off
|
||||
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 *) {} };
|
||||
// clang-format on
|
||||
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
|
||||
|
|
|
@ -226,14 +226,12 @@ 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 ());
|
||||
// clang-format off
|
||||
node.alarm.add (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);
|
||||
}
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
else if (callback_a)
|
||||
{
|
||||
|
@ -747,9 +745,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);
|
||||
// clang-format off
|
||||
condition.wait (lock, [& stopped = stopped, &free = free, &full = full] { return stopped || !free.empty () || !full.empty (); });
|
||||
// clang-format on
|
||||
}
|
||||
nano::message_buffer * result (nullptr);
|
||||
if (!free.empty ())
|
||||
|
|
|
@ -133,12 +133,10 @@ vote_processor (checker, active, store, observers, stats, config, logger, online
|
|||
rep_crawler (*this),
|
||||
warmed_up (0),
|
||||
block_processor (*this, write_database_queue),
|
||||
// clang-format off
|
||||
block_processor_thread ([this]() {
|
||||
nano::thread_role::set (nano::thread_role::name::block_processing);
|
||||
this->block_processor.process_blocks ();
|
||||
}),
|
||||
// clang-format on
|
||||
online_reps (ledger, network_params, config.online_weight_minimum.number ()),
|
||||
votes_cache (wallets),
|
||||
vote_uniquer (block_uniquer),
|
||||
|
@ -993,12 +991,11 @@ boost::optional<uint64_t> nano::node::work_generate_blocking (nano::root const &
|
|||
boost::optional<uint64_t> nano::node::work_generate_blocking (nano::root const & root_a, uint64_t difficulty_a, boost::optional<nano::account> const & account_a)
|
||||
{
|
||||
std::promise<boost::optional<uint64_t>> promise;
|
||||
// clang-format off
|
||||
work_generate (root_a, [&promise](boost::optional<uint64_t> opt_work_a) {
|
||||
work_generate (
|
||||
root_a, [&promise](boost::optional<uint64_t> opt_work_a) {
|
||||
promise.set_value (opt_work_a);
|
||||
},
|
||||
difficulty_a, account_a);
|
||||
// clang-format on
|
||||
return promise.get_future ().get ();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,11 @@ stats (stats_a),
|
|||
votes_cache (cache_a),
|
||||
store (store_a),
|
||||
wallets (wallets_a),
|
||||
// clang-format off
|
||||
thread ([this]() { run (); })
|
||||
{
|
||||
nano::unique_lock<std::mutex> lock (mutex);
|
||||
condition.wait (lock, [& started = started] { return started; });
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
void nano::request_aggregator::add (std::shared_ptr<nano::transport::channel> & channel_a, std::vector<std::pair<nano::block_hash, nano::root>> const & hashes_roots_a)
|
||||
{
|
||||
|
@ -34,7 +32,6 @@ void nano::request_aggregator::add (std::shared_ptr<nano::transport::channel> &
|
|||
{
|
||||
existing = requests_by_endpoint.emplace (channel_a).first;
|
||||
}
|
||||
// clang-format off
|
||||
requests_by_endpoint.modify (existing, [&hashes_roots_a, &channel_a, this](channel_pool & pool_a) {
|
||||
// This extends the lifetime of the channel, which is acceptable up to max_delay
|
||||
pool_a.channel = channel_a;
|
||||
|
@ -42,7 +39,6 @@ void nano::request_aggregator::add (std::shared_ptr<nano::transport::channel> &
|
|||
pool_a.deadline = new_deadline;
|
||||
pool_a.hashes_roots.insert (pool_a.hashes_roots.begin (), hashes_roots_a.begin (), hashes_roots_a.end ());
|
||||
});
|
||||
// clang-format on
|
||||
if (requests.size () == 1)
|
||||
{
|
||||
lock.unlock ();
|
||||
|
@ -85,16 +81,12 @@ void nano::request_aggregator::run ()
|
|||
else
|
||||
{
|
||||
auto deadline = front->deadline;
|
||||
// clang-format off
|
||||
condition.wait_until (lock, deadline, [this, &deadline]() { return this->stopped || deadline < std::chrono::steady_clock::now (); });
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// clang-format off
|
||||
condition.wait_for (lock, small_delay, [this]() { return this->stopped || !this->requests.empty (); });
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +190,6 @@ void nano::request_aggregator::generate (nano::transaction const & transaction_a
|
|||
{
|
||||
hashes_l.push_back (*i);
|
||||
}
|
||||
// clang-format off
|
||||
wallets.foreach_representative ([this, &generated_l, &hashes_l, &channel_a, &transaction_a](nano::public_key const & pub_a, nano::raw_key const & prv_a) {
|
||||
auto vote (this->store.vote_generate (transaction_a, pub_a, prv_a, hashes_l));
|
||||
++generated_l;
|
||||
|
@ -206,7 +197,6 @@ void nano::request_aggregator::generate (nano::transaction const & transaction_a
|
|||
channel_a->send (confirm);
|
||||
this->votes_cache.add (vote);
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
stats.add (nano::stat::type::requests, nano::stat::detail::requests_generated, stat::dir::in, generated_l);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ void nano::signature_checker::set_thread_names (unsigned num_threads)
|
|||
|
||||
for (auto i = 0u; i < num_threads; ++i)
|
||||
{
|
||||
// clang-format off
|
||||
boost::asio::post (thread_pool, [&cv, &ready, &pending, &mutex = mutex, &promise = promises[i]]() {
|
||||
nano::unique_lock<std::mutex> lk (mutex);
|
||||
nano::thread_role::set (nano::thread_role::name::signature_checking);
|
||||
|
@ -160,7 +159,6 @@ void nano::signature_checker::set_thread_names (unsigned num_threads)
|
|||
}
|
||||
promise.set_value ();
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
// Wait until all threads have finished
|
||||
|
|
|
@ -65,9 +65,7 @@ std::function<void(boost::system::error_code const &, size_t)> nano::transport::
|
|||
|
||||
std::function<void(boost::system::error_code const &, size_t)> nano::transport::channel_tcp::tcp_callback (nano::stat::detail detail_a, nano::tcp_endpoint const & endpoint_a, std::function<void(boost::system::error_code const &, size_t)> const & callback_a) const
|
||||
{
|
||||
// clang-format off
|
||||
return [endpoint_a, node = std::weak_ptr<nano::node> (node.shared ()), callback_a ](boost::system::error_code const & ec, size_t size_a)
|
||||
{
|
||||
return [endpoint_a, node = std::weak_ptr<nano::node> (node.shared ()), callback_a](boost::system::error_code const & ec, size_t size_a) {
|
||||
if (auto node_l = node.lock ())
|
||||
{
|
||||
if (!ec)
|
||||
|
@ -84,7 +82,6 @@ std::function<void(boost::system::error_code const &, size_t)> nano::transport::
|
|||
}
|
||||
}
|
||||
};
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
std::string nano::transport::channel_tcp::to_string () const
|
||||
|
@ -564,7 +561,6 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
|||
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||
if (auto socket_l = channel_a->socket.lock ())
|
||||
{
|
||||
// clang-format off
|
||||
auto cleanup_and_udp_fallback = [socket_w = channel_a->socket, node_w](nano::endpoint const & endpoint_a, std::function<void(std::shared_ptr<nano::transport::channel>)> const & callback_a) {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
|
@ -576,7 +572,6 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
|||
}
|
||||
}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
socket_l->async_read (receive_buffer_a, 8 + sizeof (nano::account) + sizeof (nano::account) + sizeof (nano::signature), [node_w, channel_a, endpoint_a, receive_buffer_a, callback_a, cleanup_and_udp_fallback](boost::system::error_code const & ec, size_t size_a) {
|
||||
if (auto node_l = node_w.lock ())
|
||||
|
|
|
@ -41,9 +41,7 @@ void nano::transport::channel_udp::send_buffer (nano::shared_const_buffer const
|
|||
|
||||
std::function<void(boost::system::error_code const &, size_t)> nano::transport::channel_udp::callback (nano::stat::detail detail_a, std::function<void(boost::system::error_code const &, size_t)> const & callback_a) const
|
||||
{
|
||||
// clang-format off
|
||||
return [node = std::weak_ptr<nano::node> (channels.node.shared ()), callback_a ](boost::system::error_code const & ec, size_t size_a)
|
||||
{
|
||||
return [node = std::weak_ptr<nano::node> (channels.node.shared ()), callback_a](boost::system::error_code const & ec, size_t size_a) {
|
||||
if (auto node_l = node.lock ())
|
||||
{
|
||||
if (ec == boost::system::errc::host_unreachable)
|
||||
|
@ -61,7 +59,6 @@ std::function<void(boost::system::error_code const &, size_t)> nano::transport::
|
|||
}
|
||||
}
|
||||
};
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
std::string nano::transport::channel_udp::to_string () const
|
||||
|
@ -318,7 +315,6 @@ void nano::transport::udp_channels::stop ()
|
|||
|
||||
// On test-net, close directly to avoid address-reuse issues. On livenet, close
|
||||
// through the strand as multiple IO threads may access the socket.
|
||||
// clang-format off
|
||||
if (node.network_params.network.is_test_network ())
|
||||
{
|
||||
this->close_socket ();
|
||||
|
@ -329,7 +325,6 @@ void nano::transport::udp_channels::stop ()
|
|||
this->close_socket ();
|
||||
});
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void nano::transport::udp_channels::close_socket ()
|
||||
|
|
|
@ -87,14 +87,10 @@ void nano::vote_generator::run ()
|
|||
}
|
||||
else
|
||||
{
|
||||
// clang-format off
|
||||
condition.wait_for (lock, config.vote_generator_delay, [this]() { return this->hashes.size () >= nano::network::confirm_ack_hashes_max; });
|
||||
// clang-format on
|
||||
if (hashes.size () >= config.vote_generator_threshold && hashes.size () < nano::network::confirm_ack_hashes_max)
|
||||
{
|
||||
// clang-format off
|
||||
condition.wait_for (lock, config.vote_generator_delay, [this]() { return this->hashes.size () >= nano::network::confirm_ack_hashes_max; });
|
||||
// clang-format on
|
||||
}
|
||||
if (!hashes.empty ())
|
||||
{
|
||||
|
|
|
@ -1038,8 +1038,7 @@ std::shared_ptr<nano::block> nano::wallet::send_action (nano::account const & so
|
|||
id_mdb_val = nano::mdb_val (id_a->size (), const_cast<char *> (id_a->data ()));
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
auto prepare_send = [&id_mdb_val, &wallets = this->wallets, &store = this->store, &source_a, &amount_a, &work_a, &account_a] (const auto & transaction) {
|
||||
auto prepare_send = [&id_mdb_val, &wallets = this->wallets, &store = this->store, &source_a, &amount_a, &work_a, &account_a](const auto & transaction) {
|
||||
auto block_transaction (wallets.node.store.tx_begin_read ());
|
||||
auto error (false);
|
||||
auto cached_block (false);
|
||||
|
@ -1085,7 +1084,7 @@ std::shared_ptr<nano::block> nano::wallet::send_action (nano::account const & so
|
|||
{
|
||||
store.work_get (transaction, source_a, work_a);
|
||||
}
|
||||
block = std::make_shared <nano::state_block> (source_a, info.head, info.representative, balance - amount_a, account_a, prv, source_a, work_a);
|
||||
block = std::make_shared<nano::state_block> (source_a, info.head, info.representative, balance - amount_a, account_a, prv, source_a, work_a);
|
||||
if (id_mdb_val && block != nullptr)
|
||||
{
|
||||
auto status (mdb_put (wallets.env.tx (transaction), wallets.node.wallets.send_action_ids, *id_mdb_val, nano::mdb_val (block->hash ()), 0));
|
||||
|
@ -1101,7 +1100,6 @@ std::shared_ptr<nano::block> nano::wallet::send_action (nano::account const & so
|
|||
}
|
||||
return std::make_tuple (block, error, cached_block);
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
std::tuple<std::shared_ptr<nano::block>, bool, bool> result;
|
||||
{
|
||||
|
@ -1158,12 +1156,11 @@ bool nano::wallet::change_sync (nano::account const & source_a, nano::account co
|
|||
{
|
||||
std::promise<bool> result;
|
||||
std::future<bool> future = result.get_future ();
|
||||
// clang-format off
|
||||
change_async (source_a, representative_a, [&result](std::shared_ptr<nano::block> block_a) {
|
||||
change_async (
|
||||
source_a, representative_a, [&result](std::shared_ptr<nano::block> block_a) {
|
||||
result.set_value (block_a == nullptr);
|
||||
},
|
||||
true);
|
||||
// clang-format on
|
||||
return future.get ();
|
||||
}
|
||||
|
||||
|
@ -1180,12 +1177,11 @@ bool nano::wallet::receive_sync (std::shared_ptr<nano::block> block_a, nano::acc
|
|||
{
|
||||
std::promise<bool> result;
|
||||
std::future<bool> future = result.get_future ();
|
||||
// clang-format off
|
||||
receive_async (block_a, representative_a, amount_a, [&result](std::shared_ptr<nano::block> block_a) {
|
||||
receive_async (
|
||||
block_a, representative_a, amount_a, [&result](std::shared_ptr<nano::block> block_a) {
|
||||
result.set_value (block_a == nullptr);
|
||||
},
|
||||
true);
|
||||
// clang-format on
|
||||
return future.get ();
|
||||
}
|
||||
|
||||
|
@ -1202,12 +1198,11 @@ nano::block_hash nano::wallet::send_sync (nano::account const & source_a, nano::
|
|||
{
|
||||
std::promise<nano::block_hash> result;
|
||||
std::future<nano::block_hash> future = result.get_future ();
|
||||
// clang-format off
|
||||
send_async (source_a, account_a, amount_a, [&result](std::shared_ptr<nano::block> block_a) {
|
||||
send_async (
|
||||
source_a, account_a, amount_a, [&result](std::shared_ptr<nano::block> block_a) {
|
||||
result.set_value (block_a->hash ());
|
||||
},
|
||||
true);
|
||||
// clang-format on
|
||||
return future.get ();
|
||||
}
|
||||
|
||||
|
@ -1907,11 +1902,9 @@ void nano::wallets::split_if_needed (nano::transaction & transaction_destination
|
|||
std::string beginning (nano::uint256_union (0).to_string ());
|
||||
std::string end ((nano::uint256_union (nano::uint256_t (0) - nano::uint256_t (1))).to_string ());
|
||||
|
||||
// clang-format off
|
||||
auto get_store_it = [&handle = handle](nano::transaction const & transaction_source, std::string const & hash) {
|
||||
auto get_store_it = [& handle = handle](nano::transaction const & transaction_source, std::string const & hash) {
|
||||
return nano::store_iterator<std::array<char, 64>, nano::no_value> (std::make_unique<nano::mdb_iterator<std::array<char, 64>, nano::no_value>> (transaction_source, handle, nano::mdb_val (hash.size (), const_cast<char *> (hash.c_str ()))));
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// First do a read pass to check if there are any wallets that need extracting (to save holding a write lock and potentially being blocked)
|
||||
auto wallets_need_splitting (false);
|
||||
|
|
|
@ -218,7 +218,6 @@ void nano::websocket::session::close ()
|
|||
ws_listener.get_logger ().try_log ("Websocket: session closing");
|
||||
|
||||
auto this_l (shared_from_this ());
|
||||
// clang-format off
|
||||
boost::asio::dispatch (strand,
|
||||
[this_l]() {
|
||||
boost::beast::websocket::close_reason reason;
|
||||
|
@ -227,12 +226,10 @@ void nano::websocket::session::close ()
|
|||
boost::system::error_code ec_ignore;
|
||||
this_l->ws.close (reason, ec_ignore);
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void nano::websocket::session::write (nano::websocket::message message_a)
|
||||
{
|
||||
// clang-format off
|
||||
nano::unique_lock<std::mutex> lk (subscriptions_mutex);
|
||||
auto subscription (subscriptions.find (message_a.topic));
|
||||
if (message_a.topic == nano::websocket::topic::ack || (subscription != subscriptions.end () && !subscription->second->should_filter (message_a)))
|
||||
|
@ -249,7 +246,6 @@ void nano::websocket::session::write (nano::websocket::message message_a)
|
|||
}
|
||||
});
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void nano::websocket::session::write_queued_messages ()
|
||||
|
@ -257,7 +253,6 @@ void nano::websocket::session::write_queued_messages ()
|
|||
auto msg (send_queue.front ().to_string ());
|
||||
auto this_l (shared_from_this ());
|
||||
|
||||
// clang-format off
|
||||
ws.async_write (nano::shared_const_buffer (msg),
|
||||
boost::asio::bind_executor (strand,
|
||||
[this_l](boost::system::error_code ec, std::size_t bytes_transferred) {
|
||||
|
@ -270,14 +265,12 @@ void nano::websocket::session::write_queued_messages ()
|
|||
}
|
||||
}
|
||||
}));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void nano::websocket::session::read ()
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
|
||||
// clang-format off
|
||||
boost::asio::post (strand, [this_l]() {
|
||||
this_l->ws.async_read (this_l->read_buffer,
|
||||
boost::asio::bind_executor (this_l->strand,
|
||||
|
@ -309,7 +302,6 @@ void nano::websocket::session::read ()
|
|||
}
|
||||
}));
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
namespace
|
||||
|
|
|
@ -16,12 +16,10 @@ nano::write_guard::~write_guard ()
|
|||
}
|
||||
|
||||
nano::write_database_queue::write_database_queue () :
|
||||
// clang-format off
|
||||
guard_finish_callback ([&queue = queue, &mutex = mutex]() {
|
||||
guard_finish_callback ([& queue = queue, &mutex = mutex]() {
|
||||
nano::lock_guard<std::mutex> guard (mutex);
|
||||
queue.pop_front ();
|
||||
})
|
||||
// clang-format on
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,11 @@ thread ([this]() {
|
|||
{
|
||||
connections.push_back (std::make_shared<nano::ipc_connection> (nano::ipc::ipc_client (io_ctx), false));
|
||||
auto connection = this->connections.back ();
|
||||
// clang-format off
|
||||
connection->client.async_connect (ipc_address, ipc_port, [ connection, &connections_mutex = this->connections_mutex ](nano::error err) {
|
||||
connection->client.async_connect (ipc_address, ipc_port, [connection, &connections_mutex = this->connections_mutex](nano::error err) {
|
||||
// Even if there is an error this needs to be set so that another attempt can be made to connect with the ipc connection
|
||||
nano::lock_guard<std::mutex> lk (connections_mutex);
|
||||
connection->is_available = true;
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7074,7 +7074,6 @@ TEST (rpc, database_txn_tracker)
|
|||
rpc.start ();
|
||||
|
||||
boost::property_tree::ptree request;
|
||||
// clang-format off
|
||||
auto check_not_correct_amount = [&system, &request, &rpc_port = rpc.config.port]() {
|
||||
test_response response (request, rpc_port, system.io_ctx);
|
||||
system.deadline_set (5s);
|
||||
|
@ -7086,7 +7085,6 @@ TEST (rpc, database_txn_tracker)
|
|||
std::error_code ec (nano::error_common::invalid_amount);
|
||||
ASSERT_EQ (response.json.get<std::string> ("error"), ec.message ());
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
request.put ("action", "database_txn_tracker");
|
||||
request.put ("min_read_time", "not a time");
|
||||
|
@ -7103,8 +7101,7 @@ TEST (rpc, database_txn_tracker)
|
|||
|
||||
std::promise<void> keep_txn_alive_promise;
|
||||
std::promise<void> txn_created_promise;
|
||||
// clang-format off
|
||||
std::thread thread ([&store = node->store, &keep_txn_alive_promise, &txn_created_promise]() {
|
||||
std::thread thread ([& store = node->store, &keep_txn_alive_promise, &txn_created_promise]() {
|
||||
// Use rpc_process_container as a placeholder as this thread is only instantiated by the daemon so won't be used
|
||||
nano::thread_role::set (nano::thread_role::name::rpc_process_container);
|
||||
|
||||
|
@ -7116,7 +7113,6 @@ TEST (rpc, database_txn_tracker)
|
|||
txn_created_promise.set_value ();
|
||||
keep_txn_alive_promise.get_future ().wait ();
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
txn_created_promise.get_future ().wait ();
|
||||
|
||||
|
@ -7260,8 +7256,7 @@ TEST (rpc, simultaneous_calls)
|
|||
std::atomic<int> count{ num };
|
||||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
// clang-format off
|
||||
std::thread ([&test_responses, &promise, &count, i, port = rpc.config.port ]() {
|
||||
std::thread ([&test_responses, &promise, &count, i, port = rpc.config.port]() {
|
||||
test_responses[i]->run (port);
|
||||
if (--count == 0)
|
||||
{
|
||||
|
@ -7269,7 +7264,6 @@ TEST (rpc, simultaneous_calls)
|
|||
}
|
||||
})
|
||||
.detach ();
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
promise.get_future ().wait ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue