Skip to content

Commit ab4072d

Browse files
authored
Merge pull request #528 from evoskuil/master
Stub in changes to neutrino queries.
2 parents eca8684 + dbc1a1c commit ab4072d

File tree

3 files changed

+70
-44
lines changed

3 files changed

+70
-44
lines changed

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

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool CLASS::to_minimum_unspent_outputs(output_links& out,
176176
// ----------------------------------------------------------------------------
177177

178178
TEMPLATE
179-
bool CLASS::get_filter(filter& out, const header_link& link) const NOEXCEPT
179+
bool CLASS::get_filter_body(filter& out, const header_link& link) const NOEXCEPT
180180
{
181181
table::neutrino::get_filter neutrino{};
182182
if (!store_.neutrino.find(link, neutrino))
@@ -199,8 +199,8 @@ bool CLASS::get_filter_head(hash_digest& out,
199199
}
200200

201201
TEMPLATE
202-
bool CLASS::set_filter(const header_link& link, const hash_digest& filter_head,
203-
const filter& filter) NOEXCEPT
202+
bool CLASS::set_filter_body(const header_link&,
203+
const filter&) NOEXCEPT
204204
{
205205
////// GUARD (filter redundancy)
206206
////// This is only fully effective if there is a single database thread.
@@ -210,14 +210,40 @@ bool CLASS::set_filter(const header_link& link, const hash_digest& filter_head,
210210
// ========================================================================
211211
const auto scope = store_.get_transactor();
212212

213-
// Clean single allocation failure (e.g. disk full).
214-
return store_.neutrino.put(link, table::neutrino::put_ref
215-
{
216-
{},
217-
filter_head,
218-
filter
219-
});
213+
////// Clean single allocation failure (e.g. disk full).
214+
////return store_.neutrino.put(link, table::neutrino::put_ref
215+
////{
216+
//// {},
217+
//// filter_head,
218+
//// filter
219+
////});
220+
// ========================================================================
221+
222+
return false;
223+
}
224+
225+
TEMPLATE
226+
bool CLASS::set_filter_head(const header_link&,
227+
const hash_digest&) NOEXCEPT
228+
{
229+
////// GUARD (filter redundancy)
230+
////// This is only fully effective if there is a single database thread.
231+
////if (!to_filter(link).is_terminal())
232+
//// return true;
233+
220234
// ========================================================================
235+
const auto scope = store_.get_transactor();
236+
237+
////// Clean single allocation failure (e.g. disk full).
238+
////return store_.neutrino.put(link, table::neutrino::put_ref
239+
////{
240+
//// {},
241+
//// filter_head,
242+
//// filter
243+
////});
244+
// ========================================================================
245+
246+
return false;
221247
}
222248

223249
////// Buffer (surrogate-keyed).

include/bitcoin/database/query.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,11 @@ class query
536536
uint64_t value) const NOEXCEPT;
537537

538538
/// Neutrino, set during validation with prevouts (surrogate-keyed).
539-
bool get_filter(filter& out, const header_link& link) const NOEXCEPT;
540-
bool get_filter_head(hash_digest& out,
541-
const header_link& link) const NOEXCEPT;
542-
bool set_filter(const header_link& link, const hash_digest& head,
543-
const filter& body) NOEXCEPT;
539+
bool get_filter_body(filter& out, const header_link& link) const NOEXCEPT;
540+
bool get_filter_head(hash_digest& out, const header_link& link) const NOEXCEPT;
541+
bool set_filter_body(const header_link& link, const filter& body) NOEXCEPT;
542+
bool set_filter_head(const header_link& link,
543+
const hash_digest& head) NOEXCEPT;
544544

545545
protected:
546546
/// Translate.

test/query/optional.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -142,35 +142,35 @@ BOOST_AUTO_TEST_CASE(query_optional__to_minimum_unspent_outputs__below__included
142142
BOOST_REQUIRE_EQUAL(out.front(), 0);
143143
}
144144

145-
BOOST_AUTO_TEST_CASE(query_optional__set_filter__get_filter_and_head__expected)
146-
{
147-
const auto& filter_head0 = system::null_hash;
148-
const auto filter0 = system::base16_chunk("0102030405060708090a0b0c0d0e0f");
149-
const auto& filter_head1 = system::one_hash;
150-
const auto filter1 = system::base16_chunk("102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f0");
151-
152-
settings settings{};
153-
settings.path = TEST_DIRECTORY;
154-
test::chunk_store store{ settings };
155-
test::query_accessor query{ store };
156-
BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success);
157-
BOOST_REQUIRE(query.initialize(test::genesis));
158-
BOOST_REQUIRE(query.set(test::block1a, context{}, false, false));
159-
BOOST_REQUIRE(query.set_filter(0, filter_head0, filter0));
160-
BOOST_REQUIRE(query.set_filter(1, filter_head1, filter1));
161-
162-
hash_digest head{};
163-
BOOST_REQUIRE(query.get_filter_head(head, 0));
164-
BOOST_REQUIRE_EQUAL(head, filter_head0);
165-
BOOST_REQUIRE(query.get_filter_head(head, 1));
166-
BOOST_REQUIRE_EQUAL(head, filter_head1);
167-
168-
system::data_chunk out{};
169-
BOOST_REQUIRE(query.get_filter(out, 0));
170-
BOOST_REQUIRE_EQUAL(out, filter0);
171-
BOOST_REQUIRE(query.get_filter(out, 1));
172-
BOOST_REQUIRE_EQUAL(out, filter1);
173-
}
145+
////BOOST_AUTO_TEST_CASE(query_optional__set_filter__get_filter_and_head__expected)
146+
////{
147+
//// const auto& filter_head0 = system::null_hash;
148+
//// const auto filter0 = system::base16_chunk("0102030405060708090a0b0c0d0e0f");
149+
//// const auto& filter_head1 = system::one_hash;
150+
//// const auto filter1 = system::base16_chunk("102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f0");
151+
////
152+
//// settings settings{};
153+
//// settings.path = TEST_DIRECTORY;
154+
//// test::chunk_store store{ settings };
155+
//// test::query_accessor query{ store };
156+
//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success);
157+
//// BOOST_REQUIRE(query.initialize(test::genesis));
158+
//// BOOST_REQUIRE(query.set(test::block1a, context{}, false, false));
159+
//// BOOST_REQUIRE(query.set_filter(0, filter_head0, filter0));
160+
//// BOOST_REQUIRE(query.set_filter(1, filter_head1, filter1));
161+
////
162+
//// hash_digest head{};
163+
//// BOOST_REQUIRE(query.get_filter_head(head, 0));
164+
//// BOOST_REQUIRE_EQUAL(head, filter_head0);
165+
//// BOOST_REQUIRE(query.get_filter_head(head, 1));
166+
//// BOOST_REQUIRE_EQUAL(head, filter_head1);
167+
////
168+
//// system::data_chunk out{};
169+
//// BOOST_REQUIRE(query.get_filter(out, 0));
170+
//// BOOST_REQUIRE_EQUAL(out, filter0);
171+
//// BOOST_REQUIRE(query.get_filter(out, 1));
172+
//// BOOST_REQUIRE_EQUAL(out, filter1);
173+
////}
174174

175175
////BOOST_AUTO_TEST_CASE(query_optional__set_buffered_tx__get_buffered_tx__expected)
176176
////{

0 commit comments

Comments
 (0)