Modify CLI --debug_account_versions for epoch upgrade tracking (#2889)

* Modify CLI --debug_account_versions for epoch upgrade tracking
* Update commentaries
This commit is contained in:
Sergey Kroshnin 2020-08-20 18:32:05 +03:00 committed by GitHub
commit 935b2c0335
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1865,7 +1865,7 @@ int main (int argc, char * const * argv)
auto node = inactive_node->node; auto node = inactive_node->node;
auto transaction (node->store.tx_begin_read ()); auto transaction (node->store.tx_begin_read ());
std::vector<std::unordered_set<nano::account>> opened_account_versions (nano::normalized_epoch (nano::epoch::max)); std::vector<std::unordered_set<nano::account>> opened_account_versions (nano::normalized_epoch (nano::epoch::max) + 1);
// Cache the accounts in a collection to make searching quicker against unchecked keys. Group by epoch // Cache the accounts in a collection to make searching quicker against unchecked keys. Group by epoch
for (auto i (node->store.latest_begin (transaction)), n (node->store.latest_end ()); i != n; ++i) for (auto i (node->store.latest_begin (transaction)), n (node->store.latest_end ()); i != n; ++i)
@ -1878,7 +1878,7 @@ int main (int argc, char * const * argv)
opened_account_versions[epoch_idx].emplace (account); opened_account_versions[epoch_idx].emplace (account);
} }
// Iterate all pending blocks and collect the highest version for each unopened account // Iterate all pending blocks and collect the lowest version for each unopened account
std::unordered_map<nano::account, std::underlying_type_t<nano::epoch>> unopened_highest_pending; std::unordered_map<nano::account, std::underlying_type_t<nano::epoch>> unopened_highest_pending;
for (auto i (node->store.pending_begin (transaction)), n (node->store.pending_end ()); i != n; ++i) for (auto i (node->store.pending_begin (transaction)), n (node->store.pending_end ()); i != n; ++i)
{ {
@ -1890,13 +1890,13 @@ int main (int argc, char * const * argv)
}); });
if (!exists) if (!exists)
{ {
// This is an unopened account, store the highest pending version // This is an unopened account, store the lowest pending version
auto it = unopened_highest_pending.find (key.account); auto it = unopened_highest_pending.find (key.account);
auto epoch = nano::normalized_epoch (info.epoch); auto epoch = nano::normalized_epoch (info.epoch);
if (it != unopened_highest_pending.cend ()) if (it != unopened_highest_pending.cend ())
{ {
// Found it, compare against existing value // Found it, compare against existing value
if (epoch > it->second) if (epoch < it->second)
{ {
it->second = epoch; it->second = epoch;
} }