Skip to content

Commit 833d98a

Browse files
committed
[wallet] Remove unnecessary Chain::Lock parameter from ResendWalletTransactions
1 parent 52b760f commit 833d98a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/wallet/wallet.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
21232123
// and so is probably just sitting in the mempool waiting to be confirmed.
21242124
// Rebroadcasting does nothing to speed up confirmation and only damages
21252125
// privacy.
2126-
void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
2126+
void CWallet::ResendWalletTransactions()
21272127
{
21282128
// During reindex, importing and IBD, old wallet transactions become
21292129
// unconfirmed. Don't resend them as that would spam other nodes.
@@ -2142,7 +2142,8 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
21422142

21432143
int relayed_tx_count = 0;
21442144

2145-
{ // cs_wallet scope
2145+
{ // locked_chain and cs_wallet scope
2146+
auto locked_chain = chain().lock();
21462147
LOCK(cs_wallet);
21472148

21482149
// Relay transactions
@@ -2151,9 +2152,9 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
21512152
// only rebroadcast unconfirmed txes older than 5 minutes before the
21522153
// last block was found
21532154
if (wtx.nTimeReceived > m_best_block_time - 5 * 60) continue;
2154-
relayed_tx_count += wtx.RelayWalletTransaction(locked_chain) ? 1 : 0;
2155+
if (wtx.RelayWalletTransaction(*locked_chain)) ++relayed_tx_count;
21552156
}
2156-
} // cs_wallet
2157+
} // locked_chain and cs_wallet
21572158

21582159
if (relayed_tx_count > 0) {
21592160
WalletLogPrintf("%s: rebroadcast %u unconfirmed transactions\n", __func__, relayed_tx_count);
@@ -2165,8 +2166,7 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
21652166
void MaybeResendWalletTxs()
21662167
{
21672168
for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
2168-
auto locked_chain = pwallet->chain().lock();
2169-
pwallet->ResendWalletTransactions(*locked_chain);
2169+
pwallet->ResendWalletTransactions();
21702170
}
21712171
}
21722172

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
949949
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
950950
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;
951951
void ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
952-
void ResendWalletTransactions(interfaces::Chain::Lock& locked_chain);
952+
void ResendWalletTransactions();
953953
struct Balance {
954954
CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
955955
CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)

0 commit comments

Comments
 (0)