Skip to content

Commit

Permalink
Add half-sized random fanout for block propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelawless committed Feb 7, 2020
1 parent 314edeb commit c1a1e49
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions nano/node/confirmation_solicitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bool nano::confirmation_solicitor::broadcast (nano::election const & election_a)
{
nano::publish message (election_a.status.winner);
unsigned count = 0;
// Directed broadcasting to get confirmations
for (auto i (representatives.begin ()), n (representatives.end ()); i != n && count < max_representatives; ++i)
{
if (election_a.last_votes.find (i->account) == election_a.last_votes.end ())
Expand All @@ -36,6 +37,8 @@ bool nano::confirmation_solicitor::broadcast (nano::election const & election_a)
++count;
}
}
// Random flood for block propagation
network.flood_message (message, true, 0.5f);
error = false;
}
return error;
Expand Down
4 changes: 2 additions & 2 deletions nano/node/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ bool nano::network::send_votes_cache (std::shared_ptr<nano::transport::channel>
return result;
}

void nano::network::flood_message (nano::message const & message_a, bool const is_droppable_a)
void nano::network::flood_message (nano::message const & message_a, bool const is_droppable_a, float const scale_a)
{
for (auto & i : list (fanout ()))
for (auto & i : list (fanout (scale_a)))
{
i->send (message_a, nullptr, is_droppable_a);
}
Expand Down
2 changes: 1 addition & 1 deletion nano/node/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class network final
~network ();
void start ();
void stop ();
void flood_message (nano::message const &, bool const = true);
void flood_message (nano::message const &, bool const = true, float const = 1.0f);
void flood_keepalive ()
{
nano::keepalive message;
Expand Down

0 comments on commit c1a1e49

Please sign in to comment.