Broadcasting active elections blocks to discovered representatives (#711)
* Broadcasting active elections blocks * Improve formatting for clang
This commit is contained in:
parent
34b07f4ea2
commit
a9b99cedfa
2 changed files with 23 additions and 1 deletions
|
@ -254,7 +254,7 @@ void rai::network::broadcast_confirm_req (std::shared_ptr<rai::block> block_a)
|
|||
}
|
||||
if (node.config.logging.network_logging ())
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Broadcasted confirm req to %1% representatives") % list.size ());
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Broadcasted confirm req for block %1% to %2% representatives") % block_a->hash ().to_string () % list.size ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1548,6 +1548,15 @@ block_processor_thread ([this]() { this->block_processor.process_blocks (); })
|
|||
if (peers.rep_response (endpoint_a, weight_l))
|
||||
{
|
||||
BOOST_LOG (log) << boost::str (boost::format ("Found a representative at %1%") % endpoint_a);
|
||||
// Rebroadcasting all active votes to new representative
|
||||
auto blocks (active.list_blocks ());
|
||||
for (auto i (blocks.begin ()), n (blocks.end ()); i != n; ++i)
|
||||
{
|
||||
if (*i != nullptr)
|
||||
{
|
||||
this->network.send_confirm_req (endpoint_a, *i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2964,6 +2973,18 @@ bool rai::active_transactions::active (rai::block const & block_a)
|
|||
return roots.find (block_a.root ()) != roots.end ();
|
||||
}
|
||||
|
||||
// List of active blocks in elections
|
||||
std::deque<std::shared_ptr<rai::block>> rai::active_transactions::list_blocks ()
|
||||
{
|
||||
std::deque<std::shared_ptr<rai::block>> result;
|
||||
std::lock_guard<std::mutex> lock (mutex);
|
||||
for (auto i (roots.begin ()), n (roots.end ()); i != n; ++i)
|
||||
{
|
||||
result.push_back (i->election->last_winner);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
rai::active_transactions::active_transactions (rai::node & node_a) :
|
||||
node (node_a)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
// Is the root of this block in the roots container
|
||||
bool active (rai::block const &);
|
||||
void announce_votes ();
|
||||
std::deque<std::shared_ptr<rai::block>> list_blocks ();
|
||||
void stop ();
|
||||
boost::multi_index_container<
|
||||
rai::conflict_info,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue