Check bulk push availability (#3231)

This commit is contained in:
Sergey Kroshnin 2021-04-25 12:57:02 +03:00 committed by GitHub
commit 88e374ae14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -68,9 +68,14 @@ void nano::frontier_req_client::receive_frontier ()
});
}
bool nano::frontier_req_client::bulk_push_available ()
{
return bulk_push_cost < nano::bootstrap_limits::bulk_push_cost_limit && frontiers_age == std::numeric_limits<decltype (frontiers_age)>::max ();
}
void nano::frontier_req_client::unsynced (nano::block_hash const & head, nano::block_hash const & end)
{
if (bulk_push_cost < nano::bootstrap_limits::bulk_push_cost_limit && frontiers_age == std::numeric_limits<decltype (frontiers_age)>::max ())
if (bulk_push_available ())
{
attempt->add_bulk_push_target (head, end);
if (end.is_zero ())
@ -169,7 +174,7 @@ void nano::frontier_req_client::received_frontier (boost::system::error_code con
{
if (count <= count_limit)
{
while (!current.is_zero ())
while (!current.is_zero () && bulk_push_available ())
{
// We know about an account they don't.
unsynced (frontier, 0);

View file

@ -16,6 +16,7 @@ public:
void run (nano::account const & start_account_a, uint32_t const frontiers_age_a, uint32_t const count_a);
void receive_frontier ();
void received_frontier (boost::system::error_code const &, size_t);
bool bulk_push_available ();
void unsynced (nano::block_hash const &, nano::block_hash const &);
void next ();
std::shared_ptr<nano::bootstrap_client> connection;