[wallet] Remove unnecessary Chain::Lock parameter from ResendWalletTransactions

This commit is contained in:
John Newbery 2019-03-20 18:07:52 -04:00
parent 52b760fc6a
commit 833d98ae07
2 changed files with 7 additions and 7 deletions

View file

@ -2123,7 +2123,7 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
// and so is probably just sitting in the mempool waiting to be confirmed. // and so is probably just sitting in the mempool waiting to be confirmed.
// Rebroadcasting does nothing to speed up confirmation and only damages // Rebroadcasting does nothing to speed up confirmation and only damages
// privacy. // privacy.
void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain) void CWallet::ResendWalletTransactions()
{ {
// During reindex, importing and IBD, old wallet transactions become // During reindex, importing and IBD, old wallet transactions become
// unconfirmed. Don't resend them as that would spam other nodes. // unconfirmed. Don't resend them as that would spam other nodes.
@ -2142,7 +2142,8 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
int relayed_tx_count = 0; int relayed_tx_count = 0;
{ // cs_wallet scope { // locked_chain and cs_wallet scope
auto locked_chain = chain().lock();
LOCK(cs_wallet); LOCK(cs_wallet);
// Relay transactions // Relay transactions
@ -2151,9 +2152,9 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
// only rebroadcast unconfirmed txes older than 5 minutes before the // only rebroadcast unconfirmed txes older than 5 minutes before the
// last block was found // last block was found
if (wtx.nTimeReceived > m_best_block_time - 5 * 60) continue; if (wtx.nTimeReceived > m_best_block_time - 5 * 60) continue;
relayed_tx_count += wtx.RelayWalletTransaction(locked_chain) ? 1 : 0; if (wtx.RelayWalletTransaction(*locked_chain)) ++relayed_tx_count;
} }
} // cs_wallet } // locked_chain and cs_wallet
if (relayed_tx_count > 0) { if (relayed_tx_count > 0) {
WalletLogPrintf("%s: rebroadcast %u unconfirmed transactions\n", __func__, relayed_tx_count); WalletLogPrintf("%s: rebroadcast %u unconfirmed transactions\n", __func__, relayed_tx_count);
@ -2165,8 +2166,7 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
void MaybeResendWalletTxs() void MaybeResendWalletTxs()
{ {
for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) { for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
auto locked_chain = pwallet->chain().lock(); pwallet->ResendWalletTransactions();
pwallet->ResendWalletTransactions(*locked_chain);
} }
} }

View file

@ -949,7 +949,7 @@ public:
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate); ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override; void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;
void ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
void ResendWalletTransactions(interfaces::Chain::Lock& locked_chain); void ResendWalletTransactions();
struct Balance { struct Balance {
CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending) CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)