Skip to content

Commit

Permalink
AEC VOTE RETURN MAP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 20, 2024
1 parent 2297f50 commit b09e3a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions nano/node/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,10 @@ nano::election_insertion_result nano::active_transactions::insert (std::shared_p
}

// Validate a vote and apply it to the current election if one exists
nano::vote_code nano::active_transactions::vote (std::shared_ptr<nano::vote> const & vote_a)
std::unordered_map<nano::block_hash, nano::vote_code> nano::active_transactions::vote (std::shared_ptr<nano::vote> const & vote_a)
{
nano::vote_code result{ nano::vote_code::indeterminate };

// If all hashes were recently confirmed then it is a replay
unsigned recently_confirmed_counter (0);

Expand Down Expand Up @@ -642,10 +643,13 @@ bool nano::active_transactions::publish (std::shared_ptr<nano::block> const & bl
lock.lock ();
blocks.emplace (block_a->hash (), election);
lock.unlock ();
if (auto const cache = node.vote_cache.find (block_a->hash ()); cache)

auto cached = node.vote_cache.find (block_a->hash ());
for (auto const & cached_vote : cached)
{
cache->fill (election);
vote (cached_vote);
}

node.stats.inc (nano::stat::type::active, nano::stat::detail::election_block_conflict);
}
}
Expand Down
2 changes: 1 addition & 1 deletion nano/node/active_transactions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class active_transactions final
*/
nano::election_insertion_result insert (std::shared_ptr<nano::block> const &, nano::election_behavior = nano::election_behavior::normal);
// Distinguishes replay votes, cannot be determined if the block is not in any election
nano::vote_code vote (std::shared_ptr<nano::vote> const &);
std::unordered_map<nano::block_hash, nano::vote_code> vote (std::shared_ptr<nano::vote> const &);
// Is the root of this block in the roots container
bool active (nano::block const &) const;
bool active (nano::qualified_root const &) const;
Expand Down

0 comments on commit b09e3a2

Please sign in to comment.