Skip to content

Commit

Permalink
Removing direct passing of write_queue when it can be accessed throug…
Browse files Browse the repository at this point in the history
…h parent objects.
  • Loading branch information
clemahieu committed Apr 4, 2024
1 parent dc6da93 commit 66df593
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
5 changes: 2 additions & 3 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ void nano::block_processor::context::set_result (result_t const & result)
* block_processor
*/

nano::block_processor::block_processor (nano::node & node_a, nano::store::write_queue & write_queue_a) :
nano::block_processor::block_processor (nano::node & node_a) :
config{ node_a.config.block_processor },
node (node_a),
write_queue (write_queue_a),
next_log (std::chrono::steady_clock::now ())
{
batch_processed.add ([this] (auto const & items) {
Expand Down Expand Up @@ -300,7 +299,7 @@ auto nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock
{
processed_batch_t processed;

auto scoped_write_guard = write_queue.wait (nano::store::writer::process_batch);
auto scoped_write_guard = node.store.write_queue.wait (nano::store::writer::process_batch);
auto transaction (node.store.tx_begin_write ({ tables::accounts, tables::blocks, tables::pending, tables::rep_weights }));
nano::timer<std::chrono::milliseconds> timer_l;

Expand Down
4 changes: 1 addition & 3 deletions nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class node;
namespace nano::store
{
class write_transaction;
class write_queue;
}

namespace nano
Expand Down Expand Up @@ -86,7 +85,7 @@ class block_processor final
};

public:
block_processor (nano::node &, nano::store::write_queue &);
block_processor (nano::node &);
~block_processor ();

void start ();
Expand Down Expand Up @@ -127,7 +126,6 @@ class block_processor final
private: // Dependencies
block_processor_config const & config;
nano::node & node;
nano::store::write_queue & write_queue;

private:
nano::fair_queue<context, block_source> queue;
Expand Down
5 changes: 2 additions & 3 deletions nano/node/confirming_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
#include <nano/store/component.hpp>
#include <nano/store/write_queue.hpp>

nano::confirming_set::confirming_set (nano::ledger & ledger, nano::store::write_queue & write_queue, std::chrono::milliseconds batch_time) :
nano::confirming_set::confirming_set (nano::ledger & ledger, std::chrono::milliseconds batch_time) :
ledger{ ledger },
write_queue{ write_queue },
batch_time{ batch_time }
{
}
Expand Down Expand Up @@ -72,7 +71,7 @@ void nano::confirming_set::run ()
for (auto i = processing.begin (), n = processing.end (); !stopped && i != n;)
{
lock.unlock (); // Waiting for db write is potentially slow
auto guard = write_queue.wait (nano::store::writer::confirmation_height);
auto guard = ledger.store.write_queue.wait (nano::store::writer::confirmation_height);
auto tx = ledger.store.tx_begin_write ({ nano::tables::confirmation_height });
lock.lock ();
// Process items in the back buffer within a single transaction for a limited amount of time
Expand Down
7 changes: 1 addition & 6 deletions nano/node/confirming_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ namespace nano
class block;
class ledger;
}
namespace nano::store
{
class write_queue;
}

namespace nano
{
Expand All @@ -30,7 +26,7 @@ class confirming_set final
friend class confirmation_height_pruned_source_Test;

public:
confirming_set (nano::ledger & ledger, nano::store::write_queue & write_queue, std::chrono::milliseconds batch_time = std::chrono::milliseconds{ 500 });
confirming_set (nano::ledger & ledger, std::chrono::milliseconds batch_time = std::chrono::milliseconds{ 500 });
~confirming_set ();
// Adds a block to the set of blocks to be confirmed
void add (nano::block_hash const & hash);
Expand All @@ -48,7 +44,6 @@ class confirming_set final
private:
void run ();
nano::ledger & ledger;
nano::store::write_queue & write_queue;
std::chrono::milliseconds batch_time;
std::unordered_set<nano::block_hash> set;
std::unordered_set<nano::block_hash> processing;
Expand Down
4 changes: 2 additions & 2 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
tcp_listener{ std::make_shared<nano::transport::tcp_listener> (network.port, *this, config.tcp_incoming_connections_max) },
application_path (application_path_a),
port_mapping (*this),
block_processor (*this, store.write_queue),
confirming_set_impl{ std::make_unique<nano::confirming_set> (ledger, store.write_queue, config.confirming_set_batch_time) },
block_processor (*this),
confirming_set_impl{ std::make_unique<nano::confirming_set> (ledger, config.confirming_set_batch_time) },
confirming_set{ *confirming_set_impl },
active_impl{ std::make_unique<nano::active_transactions> (*this, confirming_set, block_processor) },
active{ *active_impl },
Expand Down

0 comments on commit 66df593

Please sign in to comment.