Renaming successors to blocks to be less confusing. (#1400)

This commit is contained in:
clemahieu 2018-11-20 09:02:44 -06:00 committed by GitHub
commit 32b7f2a705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 17 deletions

View file

@ -3061,20 +3061,13 @@ void rai::active_transactions::announce_votes (std::unique_lock<std::mutex> & lo
{
auto root_it (roots.find (*i));
assert (root_it != roots.end ());
for (auto successor : root_it->election->blocks)
for (auto & block : root_it->election->blocks)
{
auto successor_it (successors.find (successor.first));
if (successor_it != successors.end ())
{
assert (successor_it->second == root_it->election);
successors.erase (successor_it);
}
else
{
assert (false && "election successor not in active_transactions blocks table");
}
auto erased (blocks.erase (block.first));
(void)erased;
assert (erased == 1);
}
roots.erase (root_it);
roots.erase (*i);
}
if (unconfirmed_count > 0)
{
@ -3128,7 +3121,7 @@ bool rai::active_transactions::add (std::shared_ptr<rai::block> block_a, std::fu
{
auto election (std::make_shared<rai::election> (node, block_a, confirmation_action_a));
roots.insert (rai::conflict_info{ root, election });
successors.insert (std::make_pair (block_a->hash (), election));
blocks.insert (std::make_pair (block_a->hash (), election));
}
error = existing != roots.end ();
}
@ -3153,8 +3146,8 @@ bool rai::active_transactions::vote (std::shared_ptr<rai::vote> vote_a, bool sin
if (vote_block.which ())
{
auto block_hash (boost::get<rai::block_hash> (vote_block));
auto existing (successors.find (block_hash));
if (existing != successors.end ())
auto existing (blocks.find (block_hash));
if (existing != blocks.end ())
{
result = existing->second->vote (vote_a->account, vote_a->sequence, block_hash);
}
@ -3242,7 +3235,7 @@ bool rai::active_transactions::publish (std::shared_ptr<rai::block> block_a)
result = existing->election->publish (block_a);
if (!result)
{
successors.insert (std::make_pair (block_a->hash (), existing->election));
blocks.insert (std::make_pair (block_a->hash (), existing->election));
}
}
return result;

View file

@ -103,7 +103,7 @@ public:
boost::multi_index::indexed_by<
boost::multi_index::hashed_unique<boost::multi_index::member<rai::conflict_info, rai::block_hash, &rai::conflict_info::root>>>>
roots;
std::unordered_map<rai::block_hash, std::shared_ptr<rai::election>> successors;
std::unordered_map<rai::block_hash, std::shared_ptr<rai::election>> blocks;
std::deque<rai::election_status> confirmed;
rai::node & node;
std::mutex mutex;