Skip to content

Commit

Permalink
Move gap tracker logic into gap_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Feb 5, 2024
1 parent 647c3c4 commit 42443a6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 60 deletions.
2 changes: 0 additions & 2 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ add_library(
block_broadcast.hpp
block_publisher.cpp
block_publisher.hpp
gap_tracker.cpp
gap_tracker.hpp
blocking_observer.cpp
blocking_observer.hpp
blockprocessor.hpp
Expand Down
16 changes: 14 additions & 2 deletions nano/node/gap_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@

#include <boost/format.hpp>

nano::gap_cache::gap_cache (nano::node & node_a) :
node (node_a)
nano::gap_cache::gap_cache (nano::node & node_a, nano::block_processor & block_processor_a) :
node (node_a),
block_processor (block_processor_a)
{
block_processor.processed.add ([this] (auto const & result, auto const & block) {
switch (result.code)
{
case nano::process_result::gap_previous:
case nano::process_result::gap_source:
add (block->hash ());
break;
default:
break;
}
});
}

void nano::gap_cache::add (nano::block_hash const & hash_a, std::chrono::steady_clock::time_point time_point_a)
Expand Down
11 changes: 9 additions & 2 deletions nano/node/gap_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ class gap_information final
class gap_cache final
{
public:
explicit gap_cache (nano::node &);
gap_cache (nano::node &, nano::block_processor &);

void add (nano::block_hash const &, std::chrono::steady_clock::time_point = std::chrono::steady_clock::now ());
void erase (nano::block_hash const & hash_a);
void vote (std::shared_ptr<nano::vote> const &);
bool bootstrap_check (std::vector<nano::account> const &, nano::block_hash const &);
void bootstrap_start (nano::block_hash const & hash_a);
nano::uint128_t bootstrap_threshold ();
std::size_t size ();

private: // Dependencies
nano::node & node;
nano::block_processor & block_processor;

private:
// clang-format off
class tag_arrival {};
class tag_hash {};
Expand All @@ -50,9 +57,9 @@ class gap_cache final
boost::multi_index::member<gap_information, nano::block_hash, &gap_information::hash>>>>;
ordered_gaps blocks;
// clang-format on

std::size_t const max = 256;
nano::mutex mutex{ mutex_identifier (mutexes::gap_cache) };
nano::node & node;
};

std::unique_ptr<container_info_component> collect_container_info (gap_cache & gap_cache, std::string const & name);
Expand Down
29 changes: 0 additions & 29 deletions nano/node/gap_tracker.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions nano/node/gap_tracker.hpp

This file was deleted.

1 change: 0 additions & 1 deletion nano/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <nano/node/election.hpp>
#include <nano/node/epoch_upgrader.hpp>
#include <nano/node/gap_cache.hpp>
#include <nano/node/gap_tracker.hpp>
#include <nano/node/network.hpp>
#include <nano/node/node_observers.hpp>
#include <nano/node/nodeconfig.hpp>
Expand Down

0 comments on commit 42443a6

Please sign in to comment.