mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-29 18:05:58 +02:00
`EmplaceCoinInternalDANGER()` incremented `cachedCoinsUsage` even when `try_emplace` did not insert (duplicate key), inflating the counter. This is mostly reachable in tests today since `AssumeUTXO` does not overwrite. Increment only on successful insert, and capture `coin.DynamicMemoryUsage()` before the move so accounting uses the correct value. Fuzz: add an `EmplaceCoinInternalDANGER` path to exercise insert-only accounting. Unit test: emplace two different coins at the same outpoint (with different `DynamicMemoryUsage()`), verify `SelfTest()` passes and `AccessCoin(outpoint)` returns the first coin. Co-authored-by: Andrew Toth <andrewstoth@gmail.com> Co-authored-by: w0xlt <woltx@protonmail.com>
16 KiB
16 KiB