mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
wallet: Avoid second mapWallet lookup
This commit is contained in:
@@ -76,12 +76,12 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, const CCoin
|
||||
vErrors.clear();
|
||||
bumpedTxid.SetNull();
|
||||
AssertLockHeld(pWallet->cs_wallet);
|
||||
if (!pWallet->mapWallet.count(txid)) {
|
||||
auto it = pWallet->mapWallet.find(txid);
|
||||
if (it == pWallet->mapWallet.end()) {
|
||||
vErrors.push_back("Invalid or non-wallet transaction id");
|
||||
currentResult = BumpFeeResult::INVALID_ADDRESS_OR_KEY;
|
||||
return;
|
||||
}
|
||||
auto it = pWallet->mapWallet.find(txid);
|
||||
const CWalletTx& wtx = it->second;
|
||||
|
||||
if (!preconditionChecks(pWallet, wtx)) {
|
||||
@@ -241,12 +241,13 @@ bool CFeeBumper::commit(CWallet *pWallet)
|
||||
if (!vErrors.empty() || currentResult != BumpFeeResult::OK) {
|
||||
return false;
|
||||
}
|
||||
if (txid.IsNull() || !pWallet->mapWallet.count(txid)) {
|
||||
auto it = txid.IsNull() ? pWallet->mapWallet.end() : pWallet->mapWallet.find(txid);
|
||||
if (it == pWallet->mapWallet.end()) {
|
||||
vErrors.push_back("Invalid or non-wallet transaction id");
|
||||
currentResult = BumpFeeResult::MISC_ERROR;
|
||||
return false;
|
||||
}
|
||||
CWalletTx& oldWtx = pWallet->mapWallet[txid];
|
||||
CWalletTx& oldWtx = it->second;
|
||||
|
||||
// make sure the transaction still has no descendants and hasn't been mined in the meantime
|
||||
if (!preconditionChecks(pWallet, oldWtx)) {
|
||||
|
||||
Reference in New Issue
Block a user