Skip to content

Commit

Permalink
Merge pull request #530 from evoskuil/master
Browse files Browse the repository at this point in the history
Add set_filter_body(block) override.
  • Loading branch information
evoskuil authored Jan 5, 2025
2 parents 62067a4 + 3a3ee75 commit 04472ed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
11 changes: 11 additions & 0 deletions include/bitcoin/database/impl/query/confirm.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,17 @@ bool CLASS::set_unstrong(const header_link& link) NOEXCEPT
// ========================================================================
}

TEMPLATE
bool CLASS::set_prevouts(const header_link&, const block&) NOEXCEPT
{
// ========================================================================
const auto scope = store_.get_transactor();

// TODO: implement.
return {};
// ========================================================================
}

TEMPLATE
bool CLASS::initialize(const block& genesis) NOEXCEPT
{
Expand Down
23 changes: 15 additions & 8 deletions include/bitcoin/database/impl/query/optional.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,23 @@ bool CLASS::get_filter_head(hash_digest& out,
return true;
}

TEMPLATE
bool CLASS::set_filter_body(const header_link& link,
const block& block) NOEXCEPT
{
filter bytes{};

// compute_filter is only false if prevouts are missing.
return system::neutrino::compute_filter(bytes, block) &&
set_filter_body(link, bytes);
}

TEMPLATE
bool CLASS::set_filter_body(const header_link&,
const filter&) NOEXCEPT
{
////// GUARD (filter redundancy)
////// This is only fully effective if there is a single database thread.
////if (!to_filter(link).is_terminal())
//// return true;
if (!neutrino_enabled())
return true;

// ========================================================================
const auto scope = store_.get_transactor();
Expand All @@ -226,10 +235,8 @@ TEMPLATE
bool CLASS::set_filter_head(const header_link&,
const hash_digest&) NOEXCEPT
{
////// GUARD (filter redundancy)
////// This is only fully effective if there is a single database thread.
////if (!to_filter(link).is_terminal())
//// return true;
if (!neutrino_enabled())
return true;

// ========================================================================
const auto scope = store_.get_transactor();
Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ class query
/// Block association relies on strong (confirmed or pending).
bool set_strong(const header_link& link) NOEXCEPT;
bool set_unstrong(const header_link& link) NOEXCEPT;
bool set_prevouts(const header_link& link, const block& block) NOEXCEPT;
code block_confirmable(const header_link& link) const NOEXCEPT;
////code tx_confirmable(const tx_link& link, const context& ctx) const NOEXCEPT;
code unspent_duplicates(const header_link& coinbase,
Expand Down Expand Up @@ -538,6 +539,7 @@ class query
/// Neutrino, set during validation with prevouts (surrogate-keyed).
bool get_filter_body(filter& out, const header_link& link) const NOEXCEPT;
bool get_filter_head(hash_digest& out, const header_link& link) const NOEXCEPT;
bool set_filter_body(const header_link& link, const block& block) NOEXCEPT;
bool set_filter_body(const header_link& link, const filter& body) NOEXCEPT;
bool set_filter_head(const header_link& link,
const hash_digest& head) NOEXCEPT;
Expand Down

0 comments on commit 04472ed

Please sign in to comment.