aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-09-21 09:57:00 +0200
committerMacroFake <falke.marco@gmail.com>2022-09-21 09:57:04 +0200
commitce3cb2bbe79cf33e495ea97a1d4fa4b61ad74ab9 (patch)
tree7c3936de1d6a1c0b5fa2c6c964a45cf293e3b670
parent5964b8339ac5cfb727f33fe86c57b1764caf7857 (diff)
parentfad61573ed547615f73710cb59b2fb0ecafed127 (diff)
Merge bitcoin/bitcoin#26144: [24.x] wallet: Fix nNextResend data race in ResubmitWalletTransactions
fad61573ed547615f73710cb59b2fb0ecafed127 Fix nNextResend data race in ResubmitWalletTransactions (MacroFake) Pull request description: Identical commit id from https://github.com/bitcoin/bitcoin/pull/26132 Top commit has no ACKs. Tree-SHA512: 9404e2e10ba059c412e282abbf9bef581cf5ddcac36cf05da1dff3927b5015e12469238c402c28308a774fdd969d1039e595d5e2caca0902977ae0a72746ff43
-rw-r--r--src/wallet/wallet.cpp6
-rw-r--r--src/wallet/wallet.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index e0f1655ab7..009c539a65 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1907,7 +1907,7 @@ std::set<uint256> CWallet::GetTxConflicts(const CWalletTx& wtx) const
// mempool to relay them. On startup, we will do this for all unconfirmed
// transactions but will not ask the mempool to relay them. We do this on startup
// to ensure that our own mempool is aware of our transactions, and to also
-// initialize nNextResend so that the actual rebroadcast is scheduled. There
+// initialize m_next_resend so that the actual rebroadcast is scheduled. There
// is a privacy side effect here as not broadcasting on startup also means that we won't
// inform the world of our wallet's state, particularly if the wallet (or node) is not
// yet synced.
@@ -1941,9 +1941,9 @@ void CWallet::ResubmitWalletTransactions(bool relay, bool force)
// Do this infrequently and randomly to avoid giving away
// that these are our transactions.
- if (!force && GetTime() < nNextResend) return;
+ if (!force && GetTime() < m_next_resend) return;
// resend 12-36 hours from now, ~1 day on average.
- nNextResend = GetTime() + (12 * 60 * 60) + GetRand(24 * 60 * 60);
+ m_next_resend = GetTime() + (12 * 60 * 60) + GetRand(24 * 60 * 60);
int submitted_tx_count = 0;
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index f4ea5f1920..6a1b76505c 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -250,7 +250,7 @@ private:
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
/** The next scheduled rebroadcast of wallet transactions. */
- int64_t nNextResend = 0;
+ std::atomic<int64_t> m_next_resend{};
/** Whether this wallet will submit newly created transactions to the node's mempool and
* prompt rebroadcasts (see ResendWalletTransactions()). */
bool fBroadcastTransactions = false;