Skip to content

Commit

Permalink
Retaining historical blocks until election completion. history::votes…
Browse files Browse the repository at this point in the history
… filters by root+hash so it won't pick up votes for hashes it's not looking for.
  • Loading branch information
clemahieu committed Dec 15, 2020
1 parent a278c99 commit 9890305
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ void nano::block_processor::process_batch (nano::unique_lock<std::mutex> & lock_
// Deleting from votes cache & wallet work watcher, stop active transaction
for (auto & i : rollback_list)
{
node.history.erase (i->root ());
node.wallets.watcher->remove (*i);
// Stop all rolled back active transactions except initial
if (i->hash () != successor->hash ())
Expand Down
7 changes: 5 additions & 2 deletions nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ qualified_root (block_a->qualified_root ())
last_blocks.emplace (block_a->hash (), block_a);
}

nano::election::~election()
{
node.history.erase (root);
}

void nano::election::confirm_once (nano::unique_lock<std::mutex> & lock_a, nano::election_status_type type_a)
{
debug_assert (lock_a.owns_lock ());
Expand Down Expand Up @@ -519,8 +524,6 @@ void nano::election::remove_votes (nano::block_hash const & hash_a)
{
last_votes.erase (vote->account);
}
// Clear votes cache
node.history.erase (root);
}
}

Expand Down
1 change: 1 addition & 0 deletions nano/node/election.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class election final : public std::enable_shared_from_this<nano::election>

public: // Interface
election (nano::node &, std::shared_ptr<nano::block>, std::function<void(std::shared_ptr<nano::block>)> const &, bool, nano::election_behavior);
~election ();
std::shared_ptr<nano::block> find (nano::block_hash const &) const;
nano::election_vote_result vote (nano::account const &, uint64_t, nano::block_hash const &);
bool publish (std::shared_ptr<nano::block> const & block_a);
Expand Down

0 comments on commit 9890305

Please sign in to comment.