Limit recursive confirm_back () (#1570)
This commit is contained in:
parent
eaa8155c7a
commit
c46a4a1718
2 changed files with 11 additions and 8 deletions
|
|
@ -2980,8 +2980,9 @@ void nano::election::compute_rep_votes (nano::transaction const & transaction_a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::election::confirm_once (nano::transaction const & transaction_a)
|
void nano::election::confirm_once (nano::transaction const & transaction_a, uint8_t & depth_a)
|
||||||
{
|
{
|
||||||
|
depth_a++;
|
||||||
if (!confirmed.exchange (true))
|
if (!confirmed.exchange (true))
|
||||||
{
|
{
|
||||||
status.election_end = std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ());
|
status.election_end = std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ());
|
||||||
|
|
@ -2993,21 +2994,22 @@ void nano::election::confirm_once (nano::transaction const & transaction_a)
|
||||||
node_l->process_confirmed (winner_l);
|
node_l->process_confirmed (winner_l);
|
||||||
confirmation_action_l (winner_l);
|
confirmation_action_l (winner_l);
|
||||||
});
|
});
|
||||||
confirm_back (transaction_a);
|
confirm_back (transaction_a, depth_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::election::confirm_back (nano::transaction const & transaction_a)
|
void nano::election::confirm_back (nano::transaction const & transaction_a, uint8_t & depth_a)
|
||||||
{
|
{
|
||||||
std::vector<nano::block_hash> hashes = { status.winner->previous (), status.winner->source (), status.winner->link () };
|
std::vector<nano::block_hash> hashes = { status.winner->previous (), status.winner->source (), status.winner->link () };
|
||||||
for (auto & hash : hashes)
|
for (auto & hash : hashes)
|
||||||
{
|
{
|
||||||
if (!hash.is_zero () && !node.ledger.is_epoch_link (hash))
|
// Depth is limited to 200
|
||||||
|
if (!hash.is_zero () && !node.ledger.is_epoch_link (hash) && depth_a < 200)
|
||||||
{
|
{
|
||||||
auto existing (node.active.blocks.find (hash));
|
auto existing (node.active.blocks.find (hash));
|
||||||
if (existing != node.active.blocks.end () && !existing->second->confirmed && !existing->second->stopped && existing->second->blocks.size () == 1)
|
if (existing != node.active.blocks.end () && !existing->second->confirmed && !existing->second->stopped && existing->second->blocks.size () == 1)
|
||||||
{
|
{
|
||||||
existing->second->confirm_once (transaction_a);
|
existing->second->confirm_once (transaction_a, depth_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3077,7 +3079,8 @@ void nano::election::confirm_if_quorum (nano::transaction const & transaction_a)
|
||||||
{
|
{
|
||||||
log_votes (tally_l);
|
log_votes (tally_l);
|
||||||
}
|
}
|
||||||
confirm_once (transaction_a);
|
uint8_t depth (0);
|
||||||
|
confirm_once (transaction_a, depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ public:
|
||||||
class election : public std::enable_shared_from_this<nano::election>
|
class election : public std::enable_shared_from_this<nano::election>
|
||||||
{
|
{
|
||||||
std::function<void(std::shared_ptr<nano::block>)> confirmation_action;
|
std::function<void(std::shared_ptr<nano::block>)> confirmation_action;
|
||||||
void confirm_once (nano::transaction const &);
|
void confirm_once (nano::transaction const &, uint8_t &);
|
||||||
void confirm_back (nano::transaction const &);
|
void confirm_back (nano::transaction const &, uint8_t &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
election (nano::node &, std::shared_ptr<nano::block>, std::function<void(std::shared_ptr<nano::block>)> const &);
|
election (nano::node &, std::shared_ptr<nano::block>, std::function<void(std::shared_ptr<nano::block>)> const &);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue