mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
refactor: Use type-safe time point for CWallet::m_next_resend
This commit is contained in:
parent
75cbbfa279
commit
fa51cc9651
2 changed files with 5 additions and 4 deletions
|
@ -1916,12 +1916,12 @@ bool CWallet::ShouldResend() const
|
||||||
|
|
||||||
// Do this infrequently and randomly to avoid giving away
|
// Do this infrequently and randomly to avoid giving away
|
||||||
// that these are our transactions.
|
// that these are our transactions.
|
||||||
if (GetTime() < m_next_resend) return false;
|
if (NodeClock::now() < m_next_resend) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CWallet::GetDefaultNextResend() { return GetTime() + (12 * 60 * 60) + GetRand(24 * 60 * 60); }
|
NodeClock::time_point CWallet::GetDefaultNextResend() { return FastRandomContext{}.rand_uniform_delay(NodeClock::now() + 12h, 24h); }
|
||||||
|
|
||||||
// Resubmit transactions from the wallet to the mempool, optionally asking the
|
// Resubmit transactions from the wallet to the mempool, optionally asking the
|
||||||
// mempool to relay them. On startup, we will do this for all unconfirmed
|
// mempool to relay them. On startup, we will do this for all unconfirmed
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
#include <util/time.h>
|
||||||
#include <util/ui_change_type.h>
|
#include <util/ui_change_type.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <wallet/crypter.h>
|
#include <wallet/crypter.h>
|
||||||
|
@ -250,7 +251,7 @@ private:
|
||||||
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
|
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
|
||||||
|
|
||||||
/** The next scheduled rebroadcast of wallet transactions. */
|
/** The next scheduled rebroadcast of wallet transactions. */
|
||||||
int64_t m_next_resend{GetDefaultNextResend()};
|
NodeClock::time_point m_next_resend{GetDefaultNextResend()};
|
||||||
/** Whether this wallet will submit newly created transactions to the node's mempool and
|
/** Whether this wallet will submit newly created transactions to the node's mempool and
|
||||||
* prompt rebroadcasts (see ResendWalletTransactions()). */
|
* prompt rebroadcasts (see ResendWalletTransactions()). */
|
||||||
bool fBroadcastTransactions = false;
|
bool fBroadcastTransactions = false;
|
||||||
|
@ -348,7 +349,7 @@ private:
|
||||||
*/
|
*/
|
||||||
static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||||
|
|
||||||
static int64_t GetDefaultNextResend();
|
static NodeClock::time_point GetDefaultNextResend();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue