diff --git a/include/bitcoin/database/impl/query/query.ipp b/include/bitcoin/database/impl/query/query.ipp index d8a30aba..21860d39 100644 --- a/include/bitcoin/database/impl/query/query.ipp +++ b/include/bitcoin/database/impl/query/query.ipp @@ -98,6 +98,12 @@ bool CLASS::is_full() const NOEXCEPT return to_bool(get_space()) && !is_fault(); } +TEMPLATE +bool CLASS::is_coalesced() const NOEXCEPT +{ + return get_fork() == get_top_candidate(); +} + TEMPLATE size_t CLASS::get_space() const NOEXCEPT { @@ -110,6 +116,12 @@ code CLASS::reload(const typename Store::event_handler& handler) const NOEXCEPT return store_.reload(handler); } +TEMPLATE +code CLASS::prune(const typename Store::event_handler& handler) const NOEXCEPT +{ + return store_.prune(handler); +} + TEMPLATE code CLASS::snapshot(const typename Store::event_handler& handler) const NOEXCEPT { diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index 70c70435..65104590 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -456,8 +456,7 @@ code CLASS::prune(const event_handler& handler) NOEXCEPT }; // Prevouts resettable if all candidates confirmed (fork is candidate top). - const query query_{ *this }; - if (query_.get_fork() == query_.get_top_candidate()) + if (query{ *this }.is_coalesced()) { // zeroize table head, set body logical size to zero. prune(ec, prevout, table_t::prevout_table); diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 75e260a1..cae1bb7a 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -98,12 +98,18 @@ class query /// True if there is a disk full condition. bool is_full() const NOEXCEPT; + /// True if candidate top is fork point header. + bool is_coalesced() const NOEXCEPT; + /// Get the space required to clear the disk full condition. size_t get_space() const NOEXCEPT; /// Resume from disk full condition. code reload(const typename Store::event_handler& handler) const NOEXCEPT; + /// Prune the store while running. + code prune(const typename Store::event_handler& handler) const NOEXCEPT; + /// Snapshot the store while running. code snapshot(const typename Store::event_handler& handler) const NOEXCEPT;