mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-30 15:54:03 +02:00
Merge bitcoin/bitcoin#31449: coins,refactor: Reduce getblockstats RPC UTXO overhead estimation
5f36e0ff1erpc: fix getblockstats UTXO overhead accounting (Lőrinc)76190489e6coins: pack `Coin` height/coinbase consistently (Lőrinc)1f309d1aa2coins: make `Coin::fCoinBase` a bool (Lőrinc) Pull request description: The [`getblockstats` RPC](https://github.com/bitcoin/bitcoin/pull/10757) currently overestimates UTXO overhead by treating the `fCoinBase` bitfield as an additional `bool` in `PER_UTXO_OVERHEAD`. However, `fCoinBase` and `nHeight` are stored as bitfields and effectively packed into a single 32-bit value; counting an extra bool in the overhead calculation is unnecessary. This PR introduces the following changes across three commits: * Store `fCoinBase` as a `bool` bitfield to reduce implicit conversions at call sites. * Use a consistent height/coinbase packing style across `Coin` serialization, undo serialization, and coinstats hashing (casting `nHeight` to `uint32_t` before shifting to avoid signed-promotion UB). * Adjust UTXO overhead estimation to match the actual `Coin` layout and update the related tests accordingly. ACKs for top commit: achow101: ACK5f36e0ff1esedited: ACK5f36e0ff1evasild: ACK5f36e0ff1eoptout21: crACK5f36e0ff1eTree-SHA512: f4a44debed358e9e130da9d6fae5f89289daa34f0bdb7155edc3e9b691c219451f4c80b1e16aca5b011f0fa2fa975484ef1af4ca4563b7c6ba4ca9dd133f30be
This commit is contained in:
@@ -46,7 +46,7 @@ template <typename T>
|
||||
static void TxOutSer(T& ss, const COutPoint& outpoint, const Coin& coin)
|
||||
{
|
||||
ss << outpoint;
|
||||
ss << static_cast<uint32_t>((coin.nHeight << 1) + coin.fCoinBase);
|
||||
ss << ((uint32_t{coin.nHeight} << 1) | uint32_t{coin.fCoinBase});
|
||||
ss << coin.out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user