Skip to content

Commit

Permalink
Use tx/block/header ::get_hash() to avoid copies.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jun 11, 2024
1 parent c7c3006 commit dcef21c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/bitcoin/database/impl/query/archive.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ inline bool CLASS::is_malleated64(const block& block) const NOEXCEPT
return false;

// Pass l-value to iterator.
const auto link = to_header(block.hash());
// block.get_hash() assumes cached or is not thread safe.
const auto link = to_header(block.get_hash());
auto it = store_.txs.it(link);
if (!it)
return false;
Expand Down Expand Up @@ -887,7 +888,8 @@ TEMPLATE
header_link CLASS::set_link(const header& header, const context& ctx,
bool bypass) NOEXCEPT
{
const auto key = header.hash();
// header.get_hash() assumes cached or is not thread safe.
const auto key = header.get_hash();

////// GUARD (header redundancy)
////// This is only fully effective if there is a single database thread.
Expand Down Expand Up @@ -950,11 +952,12 @@ header_link CLASS::set_link(const block& block, const context& ctx,
// set/unset txs
// ----------------------------------------------------------------------------

// This sets only the txs of a block with header/context already archived.
TEMPLATE
header_link CLASS::set_link(const block& block) NOEXCEPT
{
// This sets only the txs of a block with header/context already archived.
const auto header_fk = to_header(block.hash());
// block.get_hash() assumes cached or is not thread safe.
const auto header_fk = to_header(block.get_hash());
if (header_fk.is_terminal())
return {};

Expand Down

0 comments on commit dcef21c

Please sign in to comment.