Skip to content

Commit

Permalink
Avoid creating temporary inproc channels
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed May 15, 2024
1 parent 58e1daa commit db4e890
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nano/node/vote_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ nano::vote_generator::vote_generator (nano::node_config const & config_a, nano::
stats (stats_a),
logger (logger_a),
is_final (is_final_a),
vote_generation_queue{ stats, nano::stat::type::vote_generator, nano::thread_role::name::vote_generator_queue, /* single threaded */ 1, /* max queue size */ 1024 * 32, /* max batch size */ 1024 * 4 }
vote_generation_queue{ stats, nano::stat::type::vote_generator, nano::thread_role::name::vote_generator_queue, /* single threaded */ 1, /* max queue size */ 1024 * 32, /* max batch size */ 1024 * 4 },
inproc_channel{ std::make_shared<nano::transport::inproc::channel> (node, node) }
{
vote_generation_queue.process_batch = [this] (auto & batch) {
process_batch (batch);
Expand Down Expand Up @@ -250,7 +251,7 @@ void nano::vote_generator::broadcast_action (std::shared_ptr<nano::vote> const &
{
network.flood_vote_pr (vote_a);
network.flood_vote (vote_a, 2.0f);
vote_processor.vote (vote_a, std::make_shared<nano::transport::inproc::channel> (node, node)); // TODO: Avoid creating a temporary channel each time
vote_processor.vote (vote_a, inproc_channel);
}

void nano::vote_generator::run ()
Expand Down
1 change: 1 addition & 0 deletions nano/node/vote_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ class vote_generator final
std::deque<candidate_t> candidates;
std::atomic<bool> stopped{ false };
std::thread thread;
std::shared_ptr<nano::transport::channel> inproc_channel;
};
}

0 comments on commit db4e890

Please sign in to comment.