Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove transaction write lock from bootstrap #1005

Merged
merged 2 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions rai/node/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void rai::frontier_req_client::receive_frontier ()
});
}

void rai::frontier_req_client::unsynced (MDB_txn * transaction_a, rai::block_hash const & head, rai::block_hash const & end)
void rai::frontier_req_client::unsynced (rai::block_hash const & head, rai::block_hash const & end)
{
if (bulk_push_cost < bulk_push_cost_limit)
{
Expand Down Expand Up @@ -273,20 +273,19 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons
{
BOOST_LOG (connection->node->log) << boost::str (boost::format ("Received %1% frontiers from %2%") % std::to_string (count) % connection->socket->remote_endpoint ());
}
rai::transaction transaction (connection->node->store.environment, nullptr, false);
if (!account.is_zero ())
{
while (!current.is_zero () && current < account)
{
// We know about an account they don't.
rai::transaction transaction (connection->node->store.environment, nullptr, true);
unsynced (transaction, info.head, 0);
unsynced (info.head, 0);
next (transaction);
}
if (!current.is_zero ())
{
if (account == current)
{
rai::transaction transaction (connection->node->store.environment, nullptr, true);
if (latest == info.head)
{
// In sync
Expand All @@ -296,7 +295,7 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons
if (connection->node->store.block_exists (transaction, latest))
{
// We know about a block they don't.
unsynced (transaction, info.head, latest);
unsynced (info.head, latest);
}
else
{
Expand All @@ -322,14 +321,11 @@ void rai::frontier_req_client::received_frontier (boost::system::error_code cons
}
else
{
while (!current.is_zero ())
{
rai::transaction transaction (connection->node->store.environment, nullptr, true);
while (!current.is_zero ())
{
// We know about an account they don't.
unsynced (transaction, info.head, 0);
next (transaction);
}
// We know about an account they don't.
unsynced (info.head, 0);
next (transaction);
}
if (connection->node->config.logging.bulk_pull_logging ())
{
Expand Down
2 changes: 1 addition & 1 deletion rai/node/bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class frontier_req_client : public std::enable_shared_from_this<rai::frontier_re
void receive_frontier ();
void received_frontier (boost::system::error_code const &, size_t);
void request_account (rai::account const &, rai::block_hash const &);
void unsynced (MDB_txn *, rai::block_hash const &, rai::block_hash const &);
void unsynced (rai::block_hash const &, rai::block_hash const &);
void next (MDB_txn *);
void insert_pull (rai::pull_info const &);
std::shared_ptr<rai::bootstrap_client> connection;
Expand Down