Skip to content

Commit

Permalink
Merge pull request #527 from evoskuil/master
Browse files Browse the repository at this point in the history
Move fees to set_block_valid().
  • Loading branch information
evoskuil authored Jan 4, 2025
2 parents d89f5b9 + 8468081 commit eca8684
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
9 changes: 4 additions & 5 deletions include/bitcoin/database/impl/query/validate.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ code CLASS::get_tx_state(uint64_t& fee, size_t& sigops, const tx_link& link,
}

TEMPLATE
bool CLASS::set_block_valid(const header_link& link) NOEXCEPT
bool CLASS::set_block_valid(const header_link& link, uint64_t fees) NOEXCEPT
{
// ========================================================================
const auto scope = store_.get_transactor();
Expand All @@ -270,14 +270,13 @@ bool CLASS::set_block_valid(const header_link& link) NOEXCEPT
{
{},
schema::block_state::valid,
0 // fees
fees
});
// ========================================================================
}

TEMPLATE
bool CLASS::set_block_confirmable(const header_link& link,
uint64_t fees) NOEXCEPT
bool CLASS::set_block_confirmable(const header_link& link) NOEXCEPT
{
// ========================================================================
const auto scope = store_.get_transactor();
Expand All @@ -287,7 +286,7 @@ bool CLASS::set_block_confirmable(const header_link& link,
{
{},
schema::block_state::confirmable,
fees
0 // fees
});
// ========================================================================
}
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ class query
bool get_timestamp(uint32_t& timestamp,
const header_link& link) const NOEXCEPT;

bool set_block_valid(const header_link& link) NOEXCEPT;
bool set_block_valid(const header_link& link, uint64_t fees) NOEXCEPT;
bool set_block_unconfirmable(const header_link& link) NOEXCEPT;
bool set_block_confirmable(const header_link& link, uint64_t fees) NOEXCEPT;
bool set_block_confirmable(const header_link& link) NOEXCEPT;

// set_txs_connected is FOR PERFORMANCE EVALUATION ONLY.
bool set_txs_connected(const header_link& link) NOEXCEPT;
Expand Down
8 changes: 4 additions & 4 deletions test/query/validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__confirmable__block_confirm
BOOST_REQUIRE_EQUAL(query.get_block_state(fees, 0), error::unvalidated);
BOOST_REQUIRE_EQUAL(fees, 0u);

BOOST_REQUIRE(query.set_block_confirmable(1, 42));
BOOST_REQUIRE(query.set_block_confirmable(1));
BOOST_REQUIRE_EQUAL(query.get_header_state(1), error::block_confirmable);
BOOST_REQUIRE_EQUAL(query.get_block_state(1), error::block_confirmable);
BOOST_REQUIRE_EQUAL(query.get_block_state(fees, 1), error::block_confirmable);
BOOST_REQUIRE_EQUAL(fees, 42u);
BOOST_REQUIRE_EQUAL(fees, 0u);
}

BOOST_AUTO_TEST_CASE(query_validate__get_block_state__valid__block_valid)
Expand All @@ -233,11 +233,11 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__valid__block_valid)
BOOST_REQUIRE(query.set(test::block1, context{}, false, false));

uint64_t fees{};
BOOST_REQUIRE(query.set_block_valid(1));
BOOST_REQUIRE(query.set_block_valid(1, 42));
BOOST_REQUIRE_EQUAL(query.get_header_state(1), error::block_valid);
BOOST_REQUIRE_EQUAL(query.get_block_state(1), error::block_valid);
BOOST_REQUIRE_EQUAL(query.get_block_state(fees, 1), error::block_valid);
BOOST_REQUIRE_EQUAL(fees, 0u);
BOOST_REQUIRE_EQUAL(fees, 42u);
}

BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unconfirmable__block_unconfirmable)
Expand Down

0 comments on commit eca8684

Please sign in to comment.