From 42b2a0ff8c7fa9211d187d826230bf799de381e7 Mon Sep 17 00:00:00 2001 From: SergiySW Date: Fri, 28 Sep 2018 04:20:19 +0300 Subject: [PATCH] Escalation for long unconfirmed elections (#1237) --- rai/node/node.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rai/node/node.cpp b/rai/node/node.cpp index de5b2004..c63a93a5 100644 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -3946,6 +3946,30 @@ void rai::active_transactions::announce_votes () auto tally_l (election_l->tally (transaction)); election_l->log_votes (tally_l); } + /* Escalation for long unconfirmed elections + Start new elections for previous block & source + if there are less than 100 active elections */ + if (i->announcements % announcement_long == 1 && roots.size () < 100) + { + auto previous_hash (election_l->status.winner->previous ()); + if (!previous_hash.is_zero ()) + { + auto previous (node.store.block_get (transaction, previous_hash)); + if (previous != nullptr) + { + start (std::move (previous)); + } + } + auto source_hash (node.ledger.block_source (transaction, *election_l->status.winner)); + if (!source_hash.is_zero ()) + { + auto source (node.store.block_get (transaction, source_hash)); + if (source != nullptr) + { + start (std::move (source)); + } + } + } } if (i->announcements < announcement_long || i->announcements % announcement_long == 1) {