coins: replace remaining HaveCoin calls with GetCoin
#34320
+149
−144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Split out of #34132 (comment).
Problem
We have two ways to check a coin exists in the db. One tries to deserialize, the other just returns whether any value is associated with the key. But we usually need the full value we probed for, and
HaveCoincannot cache the returned value, so it can trigger an extra lookup ifHaveCoinusesExistsand the caller later needs the actual value.We're already delegating most
HaveCoincalls toGetCoinanyway for the above reasons, so the current implementation ofHaveCoinis redundant.Fix
Replace
HaveCoincalls withGetCoin, reuseReadRawindbwrapper, stop ignoring deserialization failures, and readjust tests to this simpler state.See
bitcoin/src/dbwrapper.cpp
Lines 304 to 331 in cd0959c
a9b7f56/src/dbwrapper.h#L206-L241.
Notes
CCoinsViewErrorCatcher::HaveCoinand check disk space periodically #26331 did not fix Running out of disk space can leave bitcoin in a desynced state #26112.