Conversation
promag
left a comment
There was a problem hiding this comment.
Missing mapWallet[] cases.
|
General Concept ACK. I guess extending to cover |
|
Yes already on it. |
ryanofsky
left a comment
There was a problem hiding this comment.
utACK 8e1b843103235d5ded84af5d25ee1530da448d53
I guess extending to cover mapWallet[] would make sense?
Not sure specifically what is meant here, but #9680 replaces [] lookups with at() lookups to avoid inadvertently adding entries to the map when the txid doesn't exist.
src/wallet/feebumper.cpp
Outdated
There was a problem hiding this comment.
Maybe something for a followup commit, but I don't understand the txid IsNull check. If it's expected that there could be a null txid in mapWallet, there should be a comment explaining why that would happen, otherwise the check should be dropped or replaced with an assert or other error indicating that wallet state is corrupted.
There was a problem hiding this comment.
@ryanofsky I guess it's to prevent an unnecessary count() in the old code. What about:
auto it = txid.IsNull() ? pWallet->mapWallet.end() : pWallet->mapWallet.find(txid);
if (it == pWallet->mapWallet.end()) {There was a problem hiding this comment.
Thread #11039 (comment)
Good idea. I guess if the purpose of the IsNull call was to serve as a minor optimization, the intent is at still discernible, though it's also still unclear. And your new change would match previous behavior more closely, so that's good too.
I think ideally IsNull check would be dropped or actually explained, but that seems like something for a followup. Your new change would be good to add to this PR.
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Seems pointlessly verbose.
There was a problem hiding this comment.
Yeah, and there is no second lookup here so..
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
Also unnecessarily verbose.
There was a problem hiding this comment.
Yeah, and there is no second lookup here so..
8e1b843 to
f7e13ef
Compare
|
@jonasschnelli leaving |
f7e13ef to
8f2f1e0
Compare
| throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); | ||
| } | ||
| const CWalletTx& wtx = pwallet->mapWallet[hash]; | ||
| const CWalletTx& wtx = it->second; |
There was a problem hiding this comment.
IMO also use this in the other cases you're using it->second.
|
utACK 8f2f1e0 |
8f2f1e0 wallet: Avoid second mapWallet lookup (João Barbosa) Pull request description: All calls to `mapWallet.count()` have the intent to detect if a `txid` exists and most are followed by a second lookup to retrieve the `CWalletTx`. This PR replaces all `mapWallet.count()` calls with `mapWallet.find()` to avoid the second lookup. Tree-SHA512: 96b7de7f5520ebf789a1aec1949a4e9c74e13683869cee012f717e5be8e51097d068e2347a36e89097c9a89f1ed1a1529db71760dac9b572e36a3e9ac1155f29
|
This brought three new -Wshadow warnings: |
8f2f1e0 wallet: Avoid second mapWallet lookup (João Barbosa) Pull request description: All calls to `mapWallet.count()` have the intent to detect if a `txid` exists and most are followed by a second lookup to retrieve the `CWalletTx`. This PR replaces all `mapWallet.count()` calls with `mapWallet.find()` to avoid the second lookup. Tree-SHA512: 96b7de7f5520ebf789a1aec1949a4e9c74e13683869cee012f717e5be8e51097d068e2347a36e89097c9a89f1ed1a1529db71760dac9b572e36a3e9ac1155f29
8f2f1e0 wallet: Avoid second mapWallet lookup (João Barbosa) Pull request description: All calls to `mapWallet.count()` have the intent to detect if a `txid` exists and most are followed by a second lookup to retrieve the `CWalletTx`. This PR replaces all `mapWallet.count()` calls with `mapWallet.find()` to avoid the second lookup. Tree-SHA512: 96b7de7f5520ebf789a1aec1949a4e9c74e13683869cee012f717e5be8e51097d068e2347a36e89097c9a89f1ed1a1529db71760dac9b572e36a3e9ac1155f29 More of 11039
All calls to
mapWallet.count()have the intent to detect if atxidexists and most are followed by a second lookup to retrieve theCWalletTx.This PR replaces all
mapWallet.count()calls withmapWallet.find()to avoid the second lookup.