From 6420c0a1049e50722f8713abb448d4d3aab11c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:01:54 +0200 Subject: [PATCH] Fix `nano::node::ongoing_bootstrap ()` transaction lifetime --- nano/node/node.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 00f6fcafa4..adeb925acb 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -891,10 +891,13 @@ void nano::node::ongoing_bootstrap () { // Find last online weight sample (last active time for node) uint64_t last_sample_time (0); - auto last_record = store.online_weight.rbegin (store.tx_begin_read ()); - if (last_record != store.online_weight.end ()) { - last_sample_time = last_record->first; + auto transaction = store.tx_begin_read (); + auto last_record = store.online_weight.rbegin (transaction); + if (last_record != store.online_weight.end ()) + { + last_sample_time = last_record->first; + } } uint64_t time_since_last_sample = std::chrono::duration_cast (std::chrono::system_clock::now ().time_since_epoch ()).count () - static_cast (last_sample_time / std::pow (10, 9)); // Nanoseconds to seconds if (time_since_last_sample + 60 * 60 < std::numeric_limits::max ())