Skip to content

Commit b6a93cc

Browse files
authored
Merge pull request #658 from evoskuil/master
Add is_coalesced() and prune(...) methods.
2 parents eff2c89 + 39fe713 commit b6a93cc

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

include/bitcoin/database/impl/query/query.ipp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ bool CLASS::is_full() const NOEXCEPT
9898
return to_bool(get_space()) && !is_fault();
9999
}
100100

101+
TEMPLATE
102+
bool CLASS::is_coalesced() const NOEXCEPT
103+
{
104+
return get_fork() == get_top_candidate();
105+
}
106+
101107
TEMPLATE
102108
size_t CLASS::get_space() const NOEXCEPT
103109
{
@@ -110,6 +116,12 @@ code CLASS::reload(const typename Store::event_handler& handler) const NOEXCEPT
110116
return store_.reload(handler);
111117
}
112118

119+
TEMPLATE
120+
code CLASS::prune(const typename Store::event_handler& handler) const NOEXCEPT
121+
{
122+
return store_.prune(handler);
123+
}
124+
113125
TEMPLATE
114126
code CLASS::snapshot(const typename Store::event_handler& handler) const NOEXCEPT
115127
{

include/bitcoin/database/impl/store.ipp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ code CLASS::prune(const event_handler& handler) NOEXCEPT
456456
};
457457

458458
// Prevouts resettable if all candidates confirmed (fork is candidate top).
459-
const query<CLASS> query_{ *this };
460-
if (query_.get_fork() == query_.get_top_candidate())
459+
if (query<CLASS>{ *this }.is_coalesced())
461460
{
462461
// zeroize table head, set body logical size to zero.
463462
prune(ec, prevout, table_t::prevout_table);

include/bitcoin/database/query.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,18 @@ class query
9898
/// True if there is a disk full condition.
9999
bool is_full() const NOEXCEPT;
100100

101+
/// True if candidate top is fork point header.
102+
bool is_coalesced() const NOEXCEPT;
103+
101104
/// Get the space required to clear the disk full condition.
102105
size_t get_space() const NOEXCEPT;
103106

104107
/// Resume from disk full condition.
105108
code reload(const typename Store::event_handler& handler) const NOEXCEPT;
106109

110+
/// Prune the store while running.
111+
code prune(const typename Store::event_handler& handler) const NOEXCEPT;
112+
107113
/// Snapshot the store while running.
108114
code snapshot(const typename Store::event_handler& handler) const NOEXCEPT;
109115

0 commit comments

Comments
 (0)