Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for txs.empty() upon association. #484

Merged
merged 2 commits into from
Jun 2, 2024
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
1 change: 1 addition & 0 deletions include/bitcoin/database/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ enum error_t : uint8_t
tx_tx_commit,

/// txs archive
txs_empty,
txs_header,
txs_txs_put,
txs_confirm
Expand Down
3 changes: 3 additions & 0 deletions include/bitcoin/database/impl/query/archive.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,9 @@ code CLASS::set_code(txs_link& out_fk, const transactions& txs,
if (key.is_terminal())
return error::txs_header;

if (txs.empty())
return error::txs_empty;

////// GUARD (block (txs) redundancy)
////// This is only fully effective if there is a single database thread.
////// Guard must be lifted for an existing top malleable association so
Expand Down
1 change: 1 addition & 0 deletions src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
{ tx_tx_commit, "tx_tx_commit" },

// tx archive
{ txs_empty, "txs_empty" },
{ txs_header, "txs_header" },
{ txs_txs_put, "txs_txs_put" },
{ txs_confirm, "txs_confirm" }
Expand Down
9 changes: 9 additions & 0 deletions test/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,15 @@ BOOST_AUTO_TEST_CASE(error_t__code__txs_header__true_exected_message)
BOOST_REQUIRE_EQUAL(ec.message(), "txs_header");
}

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

BOOST_AUTO_TEST_CASE(error_t__code__txs_txs_put__true_exected_message)
{
constexpr auto value = error::txs_txs_put;
Expand Down
Loading