Skip to content

Commit

Permalink
Consistency in calls to fanout() and using const ref for flood_vote*
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelawless committed Jan 21, 2020
1 parent 7d83472 commit 82c6cf5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions nano/core_test/peer_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ TEST (peer_container, list_fanout)
};
add_peer (9998);
ASSERT_EQ (1, node.network.size ());
ASSERT_EQ (1.0, node.network.size_sqrt ());
ASSERT_EQ (1.f, node.network.size_sqrt ());
ASSERT_EQ (1, node.network.fanout ());
auto list2 (node.network.list (node.network.fanout ()));
ASSERT_EQ (1, list2.size ());
add_peer (9999);
ASSERT_EQ (2, node.network.size ());
ASSERT_EQ (std::sqrt (2.F), node.network.size_sqrt ());
ASSERT_EQ (std::sqrt (2.f), node.network.size_sqrt ());
ASSERT_EQ (2, node.network.fanout ());
auto list3 (node.network.list (node.network.fanout ()));
ASSERT_EQ (2, list3.size ());
Expand Down
6 changes: 3 additions & 3 deletions nano/node/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void nano::network::flood_message (nano::message const & message_a, bool const i
}
}

void nano::network::flood_vote (std::shared_ptr<nano::vote> vote_a, float scale)
void nano::network::flood_vote (std::shared_ptr<nano::vote> const & vote_a, float scale)
{
nano::confirm_ack message (vote_a);
for (auto & i : list_non_pr (fanout (scale)))
Expand All @@ -229,7 +229,7 @@ void nano::network::flood_vote (std::shared_ptr<nano::vote> vote_a, float scale)
}
}

void nano::network::flood_vote_pr (std::shared_ptr<nano::vote> vote_a)
void nano::network::flood_vote_pr (std::shared_ptr<nano::vote> const & vote_a)
{
nano::confirm_ack message (vote_a);
for (auto const & i : node.rep_crawler.principal_representatives ())
Expand Down Expand Up @@ -281,7 +281,7 @@ void nano::network::broadcast_confirm_req (std::shared_ptr<nano::block> block_a)
if (list->empty () || node.rep_crawler.total_weight () < node.config.online_weight_minimum.number ())
{
// broadcast request to all peers (with max limit 2 * sqrt (peers count))
auto peers (node.network.list (std::min<size_t> (100, node.network.fanout (2.F))));
auto peers (node.network.list (std::min<size_t> (100, node.network.fanout (2.0))));
list->clear ();
list->insert (list->end (), peers.begin (), peers.end ());
}
Expand Down
4 changes: 2 additions & 2 deletions nano/node/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class network final
random_fill (message.peers);
flood_message (message);
}
void flood_vote (std::shared_ptr<nano::vote>, float scale);
void flood_vote_pr (std::shared_ptr<nano::vote>);
void flood_vote (std::shared_ptr<nano::vote> const &, float scale);
void flood_vote_pr (std::shared_ptr<nano::vote> const &);
void flood_block (std::shared_ptr<nano::block> block_a, bool const is_droppable_a = true)
{
nano::publish publish (block_a);
Expand Down

0 comments on commit 82c6cf5

Please sign in to comment.