Commit 79cabe3
committed
Merge bitcoin#25239: wallet: 'CommitTransaction', remove extra wtx lookup and add exception for db write error
57fb37c wallet: CommitTransaction, remove extra wtx lookup and add exception for a possible db write error. (furszy)
Pull request description:
Two points for `CWallet::CommitTransaction`:
1) The extra wtx lookup:
As we are calling to `AddToWallet` first, which returns the recently added/updated wtx pointer, there is no need to look up the wtx again few lines later. We can just use it.
2) The db write error:
`AddToWallet` can only return a nullptr if the db write fails, which inside `CommitTransaction` translates to an exception throw cause. We expect everywhere that `CommitTransaction` always succeed.
------------------------------------------------
Extra note:
This finding generated another working path for me :)
It starts with the following question: why are we returning a nullptr from `AddToWallet` if the db write failed without removing the recently added transaction from the wallet's map?..
Can led to a wallet invalid state where the inputs of this new transaction are not marked dirty, while the transaction that spends them still exist on the in-memory wallet tx map.
-- I'm writing it here to gather some feedback first and not forget it, will create a follow-up PR in the coming days 🚜 --
ACKs for top commit:
achow101:
ACK 57fb37c
jonatack:
ACK 57fb37c
ryanofsky:
Code review ACK 57fb37c. Seems like a clear improvement. Better to fail earlier with a better error message if the failure is going to happen anyway
Tree-SHA512: 80e59c01852cfbbc70a5de1a1c2c59b5e572f9eaa08c2175112cb515256e63fa04c7942f92a513b620d6b06e66392029ebe8902287c456efdbee58a7a5ae42da1 file changed
+7
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2106 | 2106 | | |
2107 | 2107 | | |
2108 | 2108 | | |
2109 | | - | |
| 2109 | + | |
2110 | 2110 | | |
2111 | 2111 | | |
2112 | 2112 | | |
| |||
2116 | 2116 | | |
2117 | 2117 | | |
2118 | 2118 | | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
2119 | 2124 | | |
2120 | 2125 | | |
2121 | 2126 | | |
2122 | 2127 | | |
2123 | 2128 | | |
2124 | 2129 | | |
2125 | 2130 | | |
2126 | | - | |
2127 | | - | |
2128 | | - | |
2129 | | - | |
2130 | 2131 | | |
2131 | 2132 | | |
2132 | 2133 | | |
2133 | 2134 | | |
2134 | 2135 | | |
2135 | 2136 | | |
2136 | | - | |
| 2137 | + | |
2137 | 2138 | | |
2138 | 2139 | | |
2139 | 2140 | | |
| |||
0 commit comments