Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/bitcoin/database/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ enum error_t : uint8_t
{
/// general
success,
canceled,
limited,
unknown_state,

/// integrity (internal fault)
Expand Down Expand Up @@ -136,6 +134,8 @@ enum error_t : uint8_t
/// services
not_found,
empty_block,
depth_limited,
invalid_cursor,
query_canceled,
invalid_argument,
missing_prevouts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ code CLASS::parallel_history_transform(const stopper& cancel, bool turbo,
return error::integrity;

if (cancel)
return error::canceled;
return error::query_canceled;

history::filter_sort_and_dedup(out);
return error::success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ code CLASS::parallel_outpoint_transform(const stopper& cancel, bool turbo,
return error::integrity;

if (cancel)
return error::canceled;
return error::query_canceled;

// Remove default/null points.
out.erase(std::remove_if(out.begin(), out.end(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ code CLASS::parallel_unspent_transform(const stopper& cancel, bool turbo,
return error::integrity;

if (cancel)
return error::canceled;
return error::query_canceled;

unspent::filter_sort_and_dedup(out);
return error::success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ code CLASS::to_touched_txs(const stopper& cancel, tx_links& out,
for (const auto& output: std::views::reverse(outputs))
{
if (cancel)
return error::canceled;
return error::query_canceled;

if (const auto tx = to_output_tx(output); tx.is_terminal())
return error::integrity;
Expand Down Expand Up @@ -113,13 +113,13 @@ code CLASS::to_address_outputs(const stopper& cancel, address_link& cursor,
for (cursor = it.get(); it; ++it)
{
if (cancel)
return error::canceled;
return error::query_canceled;

if (it.get() == end)
return error::success;

if (is_zero(limit--))
return error::limited;
return error::depth_limited;

table::address::record address{};
if (!store_.address.get(it, address))
Expand All @@ -128,7 +128,7 @@ code CLASS::to_address_outputs(const stopper& cancel, address_link& cursor,
out.push_back(address.output_fk);
}

return end.is_terminal() ? error::success : error::not_found;
return end.is_terminal() ? error::success : error::invalid_cursor;
}

// input|output|prevout->tx[parent]
Expand Down
4 changes: 2 additions & 2 deletions src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
{
// general
{ success, "success" },
{ canceled, "canceled" },
{ limited, "limited" },
{ unknown_state, "unknown state" },

// integrity (internal fault)
Expand Down Expand Up @@ -128,6 +126,8 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
// services
{ not_found, "not_found" },
{ empty_block, "empty_block" },
{ depth_limited, "depth_limited" },
{ invalid_cursor, "invalid_cursor" },
{ query_canceled, "query_canceled" },
{ invalid_argument, "invalid_argument" },
{ missing_prevouts, "missing_prevouts" },
Expand Down
36 changes: 18 additions & 18 deletions test/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ BOOST_AUTO_TEST_CASE(error_t__code__success__false_expected_message)
BOOST_REQUIRE_EQUAL(ec.message(), "success");
}

BOOST_AUTO_TEST_CASE(error_t__code__canceled__true_expected_message)
{
constexpr auto value = error::canceled;
const auto ec = code(value);
BOOST_REQUIRE(ec);
BOOST_REQUIRE(ec == value);
BOOST_REQUIRE_EQUAL(ec.message(), "canceled");
}

BOOST_AUTO_TEST_CASE(error_t__code__limited__true_expected_message)
{
constexpr auto value = error::limited;
const auto ec = code(value);
BOOST_REQUIRE(ec);
BOOST_REQUIRE(ec == value);
BOOST_REQUIRE_EQUAL(ec.message(), "limited");
}

BOOST_AUTO_TEST_CASE(error_t__code__unknown_state__true_expected_message)
{
constexpr auto value = error::unknown_state;
Expand Down Expand Up @@ -728,6 +710,24 @@ BOOST_AUTO_TEST_CASE(error_t__code__empty_block__true_expected_message)
BOOST_REQUIRE_EQUAL(ec.message(), "empty_block");
}

BOOST_AUTO_TEST_CASE(error_t__code__depth_limited__true_expected_message)
{
constexpr auto value = error::depth_limited;
const auto ec = code(value);
BOOST_REQUIRE(ec);
BOOST_REQUIRE(ec == value);
BOOST_REQUIRE_EQUAL(ec.message(), "depth_limited");
}

BOOST_AUTO_TEST_CASE(error_t__code__invalid_cursor__true_expected_message)
{
constexpr auto value = error::invalid_cursor;
const auto ec = code(value);
BOOST_REQUIRE(ec);
BOOST_REQUIRE(ec == value);
BOOST_REQUIRE_EQUAL(ec.message(), "invalid_cursor");
}

BOOST_AUTO_TEST_CASE(error_t__code__query_canceled__true_expected_message)
{
constexpr auto value = error::query_canceled;
Expand Down
18 changes: 9 additions & 9 deletions test/query/address/address_history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(query_address__get_history__turbo_block1a_address0__expecte
BOOST_CHECK_EQUAL(out.at(7).fee, history::missing_prevout); // tx7
}

BOOST_AUTO_TEST_CASE(query_address__get_history__limited__limited_empty)
BOOST_AUTO_TEST_CASE(query_address__get_history__limited__depth_limited_empty)
{
settings settings{};
settings.path = TEST_DIRECTORY;
Expand All @@ -132,11 +132,11 @@ BOOST_AUTO_TEST_CASE(query_address__get_history__limited__limited_empty)
const auto& hash = test::block1a_address0;

// Limited returned when limit precludes reaching the address cursor (or terminal).
BOOST_CHECK_EQUAL(query.get_history(cancel, cursor, out, hash, 0, true), error::limited);
BOOST_CHECK_EQUAL(query.get_history(cancel, cursor, out, hash, 0, true), error::depth_limited);
BOOST_CHECK(out.empty());

cursor = address_link::terminal;
BOOST_CHECK_EQUAL(query.get_history(cancel, cursor, out, hash, 8, true), error::limited);
BOOST_CHECK_EQUAL(query.get_history(cancel, cursor, out, hash, 8, true), error::depth_limited);
BOOST_CHECK(out.empty());

cursor = address_link::terminal;
Expand Down Expand Up @@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(query_address__get_unconfirmed_history__turbo_block1a_addre
BOOST_CHECK_EQUAL(out.at(3).fee, 0u); // coinbase (archived with null single point).
}

BOOST_AUTO_TEST_CASE(query_address__get_unconfirmed_history__limited__limited_empty)
BOOST_AUTO_TEST_CASE(query_address__get_unconfirmed_history__limited__depth_limited_empty)
{
settings settings{};
settings.path = TEST_DIRECTORY;
Expand All @@ -238,11 +238,11 @@ BOOST_AUTO_TEST_CASE(query_address__get_unconfirmed_history__limited__limited_em
const auto& hash = test::block1a_address0;

// Limited returned when limit precludes reaching the address cursor (or terminal).
BOOST_CHECK_EQUAL(query.get_unconfirmed_history(cancel, cursor, out, hash, 0, true), error::limited);
BOOST_CHECK_EQUAL(query.get_unconfirmed_history(cancel, cursor, out, hash, 0, true), error::depth_limited);
BOOST_CHECK(out.empty());

cursor = address_link::terminal;
BOOST_CHECK_EQUAL(query.get_unconfirmed_history(cancel, cursor, out, hash, 8, true), error::limited);
BOOST_CHECK_EQUAL(query.get_unconfirmed_history(cancel, cursor, out, hash, 8, true), error::depth_limited);
BOOST_CHECK(out.empty());

cursor = address_link::terminal;
Expand Down Expand Up @@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(query_address__get_confirmed_history__turbo_block1a_address
BOOST_CHECK_EQUAL(out.at(3).fee, history::missing_prevout); // tx6
}

BOOST_AUTO_TEST_CASE(query_address__get_confirmed_history__limited__limited_empty)
BOOST_AUTO_TEST_CASE(query_address__get_confirmed_history__limited__depth_limited_empty)
{
settings settings{};
settings.path = TEST_DIRECTORY;
Expand All @@ -310,11 +310,11 @@ BOOST_AUTO_TEST_CASE(query_address__get_confirmed_history__limited__limited_empt
const auto& hash = test::block1a_address0;

// Limited returned when limit precludes reaching address cursor (or terminal).
BOOST_CHECK_EQUAL(query.get_confirmed_history(cancel, cursor, out, hash, 0, true), error::limited);
BOOST_CHECK_EQUAL(query.get_confirmed_history(cancel, cursor, out, hash, 0, true), error::depth_limited);
BOOST_CHECK(out.empty());

cursor = address_link::terminal;
BOOST_CHECK_EQUAL(query.get_confirmed_history(cancel, cursor, out, hash, 8, true), error::limited);
BOOST_CHECK_EQUAL(query.get_confirmed_history(cancel, cursor, out, hash, 8, true), error::depth_limited);
BOOST_CHECK(out.empty());

cursor = address_link::terminal;
Expand Down
4 changes: 2 additions & 2 deletions test/query/address/address_outpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(query_address__get_address_outpoints1__genesis__expected)
BOOST_REQUIRE(*out.begin() == query.get_outpoint(query.to_output(0, 0)));
}

BOOST_AUTO_TEST_CASE(query_address__get_address_outpoints1__cancel__canceled_false)
BOOST_AUTO_TEST_CASE(query_address__get_address_outpoints1__cancel__query_canceled_false)
{
settings settings{};
settings.path = TEST_DIRECTORY;
Expand All @@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(query_address__get_address_outpoints1__cancel__canceled_fal

outpoints out{};
std::atomic_bool cancel{ true };
BOOST_REQUIRE_EQUAL(query.get_address_outpoints(cancel, out, test::genesis_address0), error::canceled);
BOOST_REQUIRE_EQUAL(query.get_address_outpoints(cancel, out, test::genesis_address0), error::query_canceled);
BOOST_REQUIRE(out.empty());
}

Expand Down
8 changes: 4 additions & 4 deletions test/query/navigate/navigate_reverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__terminal__not_reduced)
BOOST_REQUIRE_EQUAL(out.at(5), 81u);
}

BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__limit__limited)
BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__limit__depth_limited)
{
settings settings{};
settings.path = TEST_DIRECTORY;
Expand All @@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__limit__limited)
output_links out{};
address_link end{};
const std::atomic_bool cancel{};
BOOST_REQUIRE_EQUAL(query.to_address_outputs(cancel, end, out, test::block1a_address0, 4), error::limited);
BOOST_REQUIRE_EQUAL(query.to_address_outputs(cancel, end, out, test::block1a_address0, 4), error::depth_limited);

// The limit is applied before deduplication.
// There are 6 instances of the `script{ { { opcode::pick } } }` output, limited to 4.
Expand All @@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__limit__limited)
////BOOST_REQUIRE_EQUAL(out.at(5), 81u);
}

BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__stop_mismatch__populated_not_found)
BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__stop_mismatch__populated_invalid_cursor)
{
settings settings{};
settings.path = TEST_DIRECTORY;
Expand All @@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(query_navigate__to_address_outputs3__stop_mismatch__populat
address_link cursor{ 4242 };
const std::atomic_bool cancel{};
const auto ec = query.to_address_outputs(cancel, cursor, out, test::block1a_address0);
BOOST_REQUIRE_EQUAL(ec, error::not_found);
BOOST_REQUIRE_EQUAL(ec, error::invalid_cursor);

// The end was not found but the full list is returned.
BOOST_REQUIRE_EQUAL(out.size(), 6u);
Expand Down