diff --git a/include/bitcoin/database/impl/query/optional.ipp b/include/bitcoin/database/impl/query/optional.ipp index bb2ee8b0..5e917965 100644 --- a/include/bitcoin/database/impl/query/optional.ipp +++ b/include/bitcoin/database/impl/query/optional.ipp @@ -260,7 +260,7 @@ code CLASS::get_confirmed_balance(std::atomic_bool& cancel, uint64_t& balance, } TEMPLATE -std::optional CLASS::get_interval(header_link link, +std::optional CLASS::get_interval(const header_link& link, size_t height) const NOEXCEPT { // Interval is enabled by address table. @@ -283,11 +283,12 @@ std::optional CLASS::get_interval(header_link link, return {}; // Generate the leaf nodes for the span. + auto header = link; hashes leaves(span); for (auto& leaf: std::views::reverse(leaves)) { - leaf = get_header_key(link); - link = to_parent(link); + leaf = get_header_key(header); + header = to_parent(header); } // Generate the interval (merkle root) for the span ending on link header. diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 4e6680ff..97795d5b 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -572,7 +572,7 @@ class query bool turbo=false) const NOEXCEPT; /// No value if header is not at configured interval. - std::optional get_interval(header_link header, + std::optional get_interval(const header_link& link, size_t height) const NOEXCEPT; bool is_filtered_body(const header_link& link) const NOEXCEPT;