Skip to content

Commit

Permalink
refactor: remove unused locks for ResubmitWalletTransactions
Browse files Browse the repository at this point in the history
ReacceptWalletTransactions is replaced by ResubmitWalletTransactions
which already handles acquiring the necessary locks internally.

Github-Pull: #26205
Rebased-From: 01f3534
  • Loading branch information
stickies-v authored and fanquake committed Oct 13, 2022
1 parent 5ad82a0 commit a6fb674
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
20 changes: 4 additions & 16 deletions src/wallet/rpc/backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ RPCHelpMan importaddress()
if (fRescan)
{
RescanWallet(*pwallet, reserver);
{
LOCK(pwallet->cs_wallet);
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
}
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
}

return UniValue::VNULL;
Expand Down Expand Up @@ -474,10 +471,7 @@ RPCHelpMan importpubkey()
if (fRescan)
{
RescanWallet(*pwallet, reserver);
{
LOCK(pwallet->cs_wallet);
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
}
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
}

return UniValue::VNULL;
Expand Down Expand Up @@ -1395,10 +1389,7 @@ RPCHelpMan importmulti()
}
if (fRescan && fRunScan && requests.size()) {
int64_t scannedTime = pwallet->RescanFromTime(nLowestTimestamp, reserver, true /* update */);
{
LOCK(pwallet->cs_wallet);
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
}
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);

if (pwallet->IsAbortingRescan()) {
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
Expand Down Expand Up @@ -1689,10 +1680,7 @@ RPCHelpMan importdescriptors()
// Rescan the blockchain using the lowest timestamp
if (rescan) {
int64_t scanned_time = pwallet->RescanFromTime(lowest_timestamp, reserver, true /* update */);
{
LOCK(pwallet->cs_wallet);
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
}
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);

if (pwallet->IsAbortingRescan()) {
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
Expand Down
4 changes: 1 addition & 3 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3196,14 +3196,12 @@ bool CWallet::UpgradeWallet(int version, bilingual_str& error)

void CWallet::postInitProcess()
{
LOCK(cs_wallet);

// Add wallet transactions that aren't already in a block to mempool
// Do this here as mempool requires genesis block to be loaded
ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);

// Update wallet transactions with current mempool transactions.
chain().requestMempoolTransactions(*this);
WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this));
}

bool CWallet::BackupWallet(const std::string& strDest) const
Expand Down

0 comments on commit a6fb674

Please sign in to comment.