Skip to content

Commit

Permalink
Fix handling of gap_previous (#4696)
Browse files Browse the repository at this point in the history
* Only handle `gap_previous` for live traffic

* Use fwd header
  • Loading branch information
pwojcikdev authored Aug 8, 2024
1 parent b7ae57a commit 50929a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
13 changes: 8 additions & 5 deletions nano/node/bootstrap_ascending/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ nano::bootstrap_ascending::service::service (nano::node_config const & node_conf
for (auto const & [result, context] : batch)
{
debug_assert (context.block != nullptr);
inspect (transaction, result, *context.block);
inspect (transaction, result, *context.block, context.source);
}
}
condition.notify_all ();
Expand Down Expand Up @@ -189,7 +189,7 @@ std::size_t nano::bootstrap_ascending::service::score_size () const
- Marks an account as blocked if the result code is gap source as there is no reason request additional blocks for this account until the dependency is resolved
- Marks an account as forwarded if it has been recently referenced by a block that has been inserted.
*/
void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx, nano::block_status const & result, nano::block const & block)
void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx, nano::block_status const & result, nano::block const & block, nano::block_source source)
{
debug_assert (!mutex.try_lock ());

Expand Down Expand Up @@ -224,10 +224,13 @@ void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx
break;
case nano::block_status::gap_previous:
{
if (block.type () == block_type::state)
if (source == nano::block_source::live)
{
const auto account = block.account_field ().value ();
accounts.priority_set (account);
if (block.type () == block_type::state)
{
const auto account = block.account_field ().value ();
accounts.priority_set (account);
}
}
}
break;
Expand Down
18 changes: 2 additions & 16 deletions nano/node/bootstrap_ascending/service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <nano/node/bootstrap_ascending/iterators.hpp>
#include <nano/node/bootstrap_ascending/peer_scoring.hpp>
#include <nano/node/bootstrap_ascending/throttle.hpp>
#include <nano/node/fwd.hpp>

#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
Expand All @@ -22,23 +23,8 @@

namespace mi = boost::multi_index;

namespace nano::secure
{
class transaction;
}

namespace nano
{
class block_processor;
class ledger;
class network;
class node_config;

namespace transport
{
class channel;
}

namespace bootstrap_ascending
{
class service
Expand Down Expand Up @@ -108,7 +94,7 @@ namespace bootstrap_ascending

private:
/* Inspects a block that has been processed by the block processor */
void inspect (secure::transaction const &, nano::block_status const & result, nano::block const & block);
void inspect (secure::transaction const &, nano::block_status const & result, nano::block const & block, nano::block_source);

void run_priorities ();
void run_one_priority ();
Expand Down
2 changes: 2 additions & 0 deletions nano/node/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace nano
{
class active_elections;
class block;
class block_processor;
class confirming_set;
class ledger;
class local_block_broadcaster;
Expand All @@ -29,5 +30,6 @@ class vote_processor;
class vote_router;
class wallets;

enum class block_source;
enum class vote_code;
}

0 comments on commit 50929a0

Please sign in to comment.