diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a1030bf6e8d1..68fd48e5c245 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1970,10 +1970,10 @@ void CWallet::ResendWalletTransactions() // Do this infrequently and randomly to avoid giving away // that these are our transactions. - if (GetTime() < m_next_resend || !fBroadcastTransactions) return; - bool fFirst = (m_next_resend == 0); + if (NodeClock::now() < m_next_resend.load() || !fBroadcastTransactions) return; + bool fFirst = (m_next_resend.load() == NodeClock::time_point{}); // resend 1-3 hours from now, ~2 hours on average. - m_next_resend = GetTime() + (1 * 60 * 60) + GetRand(2 * 60 * 60); + m_next_resend = FastRandomContext{}.rand_uniform_delay(NodeClock::now() + 1h, 2h); if (fFirst) return; int submitted_tx_count = 0; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index aeaccbf22653..03473bccfd26 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -275,7 +276,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE}; /** The next scheduled rebroadcast of wallet transactions. */ - std::atomic m_next_resend{}; + std::atomic m_next_resend{}; /** Whether this wallet will submit newly created transactions to the node's mempool and * prompt rebroadcasts (see ResendWalletTransactions()). */ bool fBroadcastTransactions = false;