Skip to content

Commit 50cc8ef

Browse files
committed
Merge bitcoin/bitcoin#26302: refactor: Use type-safe time point for CWallet::m_next_resend
fa51cc9 refactor: Use type-safe time point for CWallet::m_next_resend (MacroFake) Pull request description: `GetTime` is not type-safe, thus deprecated, see https://github.com/bitcoin/bitcoin/blob/75cbbfa279685f70d9f6fa71432df00862ffa865/src/util/time.h#L62-L70 ACKs for top commit: shaavan: Code Review ACK fa51cc9 aureleoules: ACK fa51cc9 Tree-SHA512: 030de10070518580763ea75079442e2f934c54d3083be3ebe35e7f1bc6db2096745bb46d95aa1e6efe29ced30a048acfe5cd999178e6787b7647dfbec5ecb444
2 parents 6d40484 + fa51cc9 commit 50cc8ef

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,12 +1916,12 @@ bool CWallet::ShouldResend() const
19161916

19171917
// Do this infrequently and randomly to avoid giving away
19181918
// that these are our transactions.
1919-
if (GetTime() < m_next_resend) return false;
1919+
if (NodeClock::now() < m_next_resend) return false;
19201920

19211921
return true;
19221922
}
19231923

1924-
int64_t CWallet::GetDefaultNextResend() { return GetTime() + (12 * 60 * 60) + GetRand(24 * 60 * 60); }
1924+
NodeClock::time_point CWallet::GetDefaultNextResend() { return FastRandomContext{}.rand_uniform_delay(NodeClock::now() + 12h, 24h); }
19251925

19261926
// Resubmit transactions from the wallet to the mempool, optionally asking the
19271927
// mempool to relay them. On startup, we will do this for all unconfirmed

src/wallet/wallet.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <util/strencodings.h>
2121
#include <util/string.h>
2222
#include <util/system.h>
23+
#include <util/time.h>
2324
#include <util/ui_change_type.h>
2425
#include <validationinterface.h>
2526
#include <wallet/crypter.h>
@@ -250,7 +251,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
250251
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
251252

252253
/** The next scheduled rebroadcast of wallet transactions. */
253-
int64_t m_next_resend{GetDefaultNextResend()};
254+
NodeClock::time_point m_next_resend{GetDefaultNextResend()};
254255
/** Whether this wallet will submit newly created transactions to the node's mempool and
255256
* prompt rebroadcasts (see ResendWalletTransactions()). */
256257
bool fBroadcastTransactions = false;
@@ -348,7 +349,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
348349
*/
349350
static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings);
350351

351-
static int64_t GetDefaultNextResend();
352+
static NodeClock::time_point GetDefaultNextResend();
352353

353354
public:
354355
/**

0 commit comments

Comments
 (0)