Skip to content

Commit 536e8ee

Browse files
authored
Merge pull request #661 from evoskuil/master
Add query get_filter_heads(...).
2 parents 401924e + 9c19661 commit 536e8ee

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ bool CLASS::get_filter_hashes(hashes& filter_hashes,
243243
return get_filter_head(previous_header, link);
244244
}
245245

246+
TEMPLATE
247+
bool CLASS::get_filter_heads(hashes& filter_heads,
248+
size_t stop_height, size_t interval) const NOEXCEPT
249+
{
250+
size_t height{};
251+
filter_heads.resize(system::floored_divide(stop_height, interval));
252+
for (auto& head: filter_heads)
253+
if (!get_filter_head(head, to_confirmed((height += interval))))
254+
return false;
255+
256+
return true;
257+
}
258+
246259
// set_filter_body
247260
// ----------------------------------------------------------------------------
248261

include/bitcoin/database/query.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,17 @@ class query
569569

570570
bool is_filtered_body(const header_link& link) const NOEXCEPT;
571571
bool get_filter_body(filter& out, const header_link& link) const NOEXCEPT;
572-
bool set_filter_body(const header_link& link, const block& block) NOEXCEPT;
573-
bool set_filter_body(const header_link& link, const filter& body) NOEXCEPT;
574572

575573
bool is_filtered_head(const header_link& link) const NOEXCEPT;
576574
bool get_filter_head(hash_digest& out, const header_link& link) const NOEXCEPT;
577575
bool get_filter_hash(hash_digest& out, const header_link& link) const NOEXCEPT;
578576
bool get_filter_hashes(hashes& filter_hashes, hash_digest& previous_header,
579577
const header_link& stop_link, size_t count) const NOEXCEPT;
578+
bool get_filter_heads(hashes& filter_heads, size_t stop_height,
579+
size_t interval) const NOEXCEPT;
580+
581+
bool set_filter_body(const header_link& link, const block& block) NOEXCEPT;
582+
bool set_filter_body(const header_link& link, const filter& body) NOEXCEPT;
580583
bool set_filter_head(const header_link& link) NOEXCEPT;
581584
bool set_filter_head(const header_link& link, const hash_digest& head,
582585
const hash_digest& hash) NOEXCEPT;

0 commit comments

Comments
 (0)