diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index 48742d80..2e879038 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -1865,7 +1865,7 @@ int main (int argc, char * const * argv) auto node = inactive_node->node; auto transaction (node->store.tx_begin_read ()); - std::vector> opened_account_versions (nano::normalized_epoch (nano::epoch::max)); + std::vector> 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 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); } - // 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> unopened_highest_pending; 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) { - // 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 epoch = nano::normalized_epoch (info.epoch); if (it != unopened_highest_pending.cend ()) { // Found it, compare against existing value - if (epoch > it->second) + if (epoch < it->second) { it->second = epoch; }