mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-03 17:30:25 +01:00
Merge bitcoin/bitcoin#30849: refactor: migrate bool GetCoin to return optional<Coin>
4feaa28728refactor: Rely on returned value of GetCoin instead of parameter (Lőrinc)46dfbf169brefactor: Return optional of Coin in GetCoin (Lőrinc)e31bfb26c2refactor: Remove unrealistic simulation state (Lőrinc) Pull request description: While reviewing [the removal of the unreachable combinations from the Coin cache logic](https://github.com/bitcoin/bitcoin/pull/30673#discussion_r1721727681), we've noticed that the related tests often [reflect impossible states](https://github.com/bitcoin/bitcoin/pull/30673/files#r1740154464). Browsing the Coin cache refactoring history revealed that migrating `bool GetCoin` to `optional<Coin> GetCoin` was [already proposed a few times before](https://github.com/bitcoin/bitcoin/pull/18746#issuecomment-842393167). This refactor makes certain invalid states impossible, reducing the possibility of errors and making the code easier to understand. This will let us remove test code that exercises the impossible states as well. The PR is done in multiple small steps, first swapping the new `optional` return value, slowly strangling out the usages of the return parameter, followed by the removal of the parameter. Most of the invalid test states were still kept, except for https://github.com/bitcoin/bitcoin/pull/30673/files#r1748087322, where the new design prohibits invalid usage and https://github.com/bitcoin/bitcoin/pull/30673/files#r1749350258 was just marked with a TODO, will be removed in a follow-up PR. ACKs for top commit: andrewtoth: re-ACK4feaa28728achow101: ACK4feaa28728laanwj: Code review ACK4feaa28728theStack: Code-review ACK4feaa28728Tree-SHA512: 818d60b2e97f58c489a61120fe761fb67a08dffbefe7a3fce712d362fc9eb8c2cced23074f1bec55fe71c616a3561b5a8737919ad6ffb2635467ec4711683df7
This commit is contained in:
@@ -358,9 +358,7 @@ public:
|
||||
std::optional<Coin> getUnspentOutput(const COutPoint& output) override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
Coin coin;
|
||||
if (chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin)) return coin;
|
||||
return {};
|
||||
return chainman().ActiveChainstate().CoinsTip().GetCoin(output);
|
||||
}
|
||||
TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user