Skip to content

Commit

Permalink
Merge pull request #484 from evoskuil/master
Browse files Browse the repository at this point in the history
Check for txs.empty() upon association.
  • Loading branch information
evoskuil authored Jun 2, 2024
2 parents eebe66b + e32eb7c commit 70962ad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
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

0 comments on commit 70962ad

Please sign in to comment.