Merge bitcoin/bitcoin#33855: kernel: add btck_block_tree_entry_equals

096924d39d kernel: add btck_block_tree_entry_equals (stickies-v)

Pull request description:

  `BlockTreeEntry` objects are often compared. This happens frequently in our own codebase and seems likely to be the case for clients, too. Users can already work around this by comparing based on block hash (and optionally height as belt-and-suspenders), but I think this should be part of the interface for performance and consistency reasons.

  Note: perhaps this is too ad-hoc, and we should extend this PR to add the operator for more types? `BlockTreeEntry` is the main one I've needed this for in developing `py-bitcoinkernel`, though.

ACKs for top commit:
  maflcko:
    review ACK 096924d39d 📓
  TheCharlatan:
    ACK 096924d39d
  yuvicc:
    Code Review ACK 096924d39d

Tree-SHA512: a0c08c01ab6c855aec4e2b2b898e9550493cd4cf8c6e1fe9e4fe5039d0d9ef3bffb2f2ab0454c7cc449b9deedd7889f5fd7b5f100fa706a855023af4adb803c6
This commit is contained in:
merge-script
2025-11-25 12:31:17 +00:00
4 changed files with 63 additions and 0 deletions

View File

@@ -1117,6 +1117,11 @@ const btck_BlockHash* btck_block_tree_entry_get_block_hash(const btck_BlockTreeE
return btck_BlockHash::ref(btck_BlockTreeEntry::get(entry).phashBlock);
}
int btck_block_tree_entry_equals(const btck_BlockTreeEntry* entry1, const btck_BlockTreeEntry* entry2)
{
return &btck_BlockTreeEntry::get(entry1) == &btck_BlockTreeEntry::get(entry2);
}
btck_BlockHash* btck_block_hash_create(const unsigned char block_hash[32])
{
return btck_BlockHash::create(std::span<const unsigned char>{block_hash, 32});