Skip to content

Commit

Permalink
Rebroadcast cleanup steemit#1661
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vandeberg committed Oct 17, 2017
1 parent b5117f9 commit 93a9fd7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@

#include <boost/range/adaptor/reversed.hpp>

// Every 3-6 blocks, rebroadcast. Do this randomly to prevent simultaneous p2p spam.
#define REBROADCAST_RAND_INTERVAL() 3 + ( rand() % 4 )

namespace steemit { namespace app {
using graphene::net::item_hash_t;
using graphene::net::item_id;
Expand Down Expand Up @@ -240,7 +243,7 @@ namespace detail {
{
if( _chain_db->head_block_num() >= _next_rebroadcast )
{
_next_rebroadcast += 3 + ( rand() % 4 ); // Every 3-6 blocks, rebroadcast. Do this randomly to prevent simultaneous p2p spam.
_next_rebroadcast += REBROADCAST_RAND_INTERVAL();
for( const auto& trx : _chain_db->_pending_tx )
{
_p2p_network->broadcast( graphene::net::trx_message( trx ) );
Expand Down Expand Up @@ -365,8 +368,8 @@ namespace detail {
}
_chain_db->show_free_memory( true );

_next_rebroadcast = _chain_db->head_block_num() + 3 + rand() % 4;
_rebroadcast_con = _chain_db->applied_block.connect( [&]( const signed_block& b ){ rebroadcast_pending_tx(); } );
_next_rebroadcast = _chain_db->head_block_num() + REBROADCAST_RAND_INTERVAL();
_rebroadcast_con = _chain_db->applied_block.connect( [this]( const signed_block& b ){ rebroadcast_pending_tx(); } );

if( _options->count("api-user") )
{
Expand Down

0 comments on commit 93a9fd7

Please sign in to comment.