Skip to content

Commit

Permalink
Batch erase in unchecked_cleanup due to a potentially large list
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelawless committed Mar 6, 2020
1 parent ab43d93 commit 282e008
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 3 additions & 6 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ void nano::node::bootstrap_wallet ()

void nano::node::unchecked_cleanup ()
{
std::vector<std::shared_ptr<nano::block>> blocks;
std::vector<nano::uint128_t> digests;
std::deque<nano::unchecked_key> cleaning_list;
auto attempt (bootstrap_initiator.current_attempt ());
bool long_attempt (attempt != nullptr && std::chrono::duration_cast<std::chrono::seconds> (std::chrono::steady_clock::now () - attempt->attempt_start).count () > config.unchecked_cutoff_time.count ());
Expand All @@ -949,7 +949,7 @@ void nano::node::unchecked_cleanup ()
nano::unchecked_info const & info (i->second);
if ((now - info.modified) > static_cast<uint64_t> (config.unchecked_cutoff_time.count ()))
{
blocks.push_back (info.block);
digests.push_back (network.publish_filter.hash (info.block));
cleaning_list.push_back (key);
}
}
Expand All @@ -976,10 +976,7 @@ void nano::node::unchecked_cleanup ()
}
}
// Delete from the duplicate filter
for (auto const & block : blocks)
{
network.publish_filter.clear (block);
}
network.publish_filter.clear (digests);
}

void nano::node::ongoing_unchecked_cleanup ()
Expand Down
1 change: 1 addition & 0 deletions nano/secure/network_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ nano::uint128_t nano::network_filter::hash (uint8_t const * bytes_a, size_t coun
}

// Explicitly instantiate
template nano::uint128_t nano::network_filter::hash (std::shared_ptr<nano::block> const &) const;
template void nano::network_filter::clear (std::shared_ptr<nano::block> const &);

0 comments on commit 282e008

Please sign in to comment.