mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-15 01:58:09 +02:00
wallet: Move CWallet::ReacceptWalletTransactions locks to callers
This commit is contained in:
@@ -1861,13 +1861,11 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
||||
return result;
|
||||
}
|
||||
|
||||
void CWallet::ReacceptWalletTransactions()
|
||||
void CWallet::ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain)
|
||||
{
|
||||
// If transactions aren't being broadcasted, don't let them into local mempool either
|
||||
if (!fBroadcastTransactions)
|
||||
return;
|
||||
auto locked_chain = chain().lock();
|
||||
LOCK(cs_wallet);
|
||||
std::map<int64_t, CWalletTx*> mapSorted;
|
||||
|
||||
// Sort pending wallet transactions based on their initial wallet insertion order
|
||||
@@ -1877,7 +1875,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
CWalletTx& wtx = item.second;
|
||||
assert(wtx.GetHash() == wtxid);
|
||||
|
||||
int nDepth = wtx.GetDepthInMainChain(*locked_chain);
|
||||
int nDepth = wtx.GetDepthInMainChain(locked_chain);
|
||||
|
||||
if (!wtx.IsCoinBase() && (nDepth == 0 && !wtx.isAbandoned())) {
|
||||
mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx));
|
||||
@@ -1888,7 +1886,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
for (const std::pair<const int64_t, CWalletTx*>& item : mapSorted) {
|
||||
CWalletTx& wtx = *(item.second);
|
||||
CValidationState state;
|
||||
wtx.AcceptToMemoryPool(*locked_chain, state);
|
||||
wtx.AcceptToMemoryPool(locked_chain, state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4398,9 +4396,12 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
||||
|
||||
void CWallet::postInitProcess()
|
||||
{
|
||||
auto locked_chain = chain().lock();
|
||||
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
|
||||
ReacceptWalletTransactions();
|
||||
ReacceptWalletTransactions(*locked_chain);
|
||||
}
|
||||
|
||||
bool CWallet::BackupWallet(const std::string& strDest)
|
||||
|
||||
Reference in New Issue
Block a user