mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-24 22:45:41 +01:00
[wallet] Keep track of the best block time in the wallet
Move nTimeBestReceived (which is only used for wallet rebroadcasts) into the wallet.
This commit is contained in:
@@ -1276,6 +1276,10 @@ void CWallet::BlockDisconnected(const CBlock& block) {
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::UpdatedBlockTip()
|
||||
{
|
||||
m_best_block_time = GetTime();
|
||||
}
|
||||
|
||||
|
||||
void CWallet::BlockUntilSyncedToCurrentChain() {
|
||||
@@ -2110,7 +2114,7 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
|
||||
return CTransaction(tx1) == CTransaction(tx2);
|
||||
}
|
||||
|
||||
void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain, int64_t nBestBlockTime)
|
||||
void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain)
|
||||
{
|
||||
// Do this infrequently and randomly to avoid giving away
|
||||
// that these are our transactions.
|
||||
@@ -2120,7 +2124,7 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain, in
|
||||
if (fFirst) return;
|
||||
|
||||
// Only do it if there's been a new block since last time
|
||||
if (nBestBlockTime < nLastResend) return;
|
||||
if (m_best_block_time < nLastResend) return;
|
||||
nLastResend = GetTime();
|
||||
|
||||
int relayed_tx_count = 0;
|
||||
@@ -2133,7 +2137,7 @@ void CWallet::ResendWalletTransactions(interfaces::Chain::Lock& locked_chain, in
|
||||
CWalletTx& wtx = item.second;
|
||||
// only rebroadcast unconfirmed txes older than 5 minutes before the
|
||||
// last block was found
|
||||
if (wtx.nTimeReceived > nBestBlockTime - 5 * 60) continue;
|
||||
if (wtx.nTimeReceived > m_best_block_time - 5 * 60) continue;
|
||||
relayed_tx_count += wtx.RelayWalletTransaction(locked_chain) ? 1 : 0;
|
||||
}
|
||||
} // cs_wallet
|
||||
|
||||
@@ -657,6 +657,8 @@ private:
|
||||
int64_t nNextResend = 0;
|
||||
int64_t nLastResend = 0;
|
||||
bool fBroadcastTransactions = false;
|
||||
// Local time that the tip block was received. Used to schedule wallet rebroadcasts.
|
||||
std::atomic<int64_t> m_best_block_time {0};
|
||||
|
||||
/**
|
||||
* Used to keep track of spent outpoints, and
|
||||
@@ -926,6 +928,7 @@ public:
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx) override;
|
||||
void BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& vtxConflicted) override;
|
||||
void BlockDisconnected(const CBlock& block) override;
|
||||
void UpdatedBlockTip() override;
|
||||
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
|
||||
|
||||
struct ScanResult {
|
||||
@@ -946,7 +949,7 @@ public:
|
||||
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
|
||||
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;
|
||||
void ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
void ResendWalletTransactions(interfaces::Chain::Lock& locked_chain, int64_t nBestBlockTime) override;
|
||||
void ResendWalletTransactions(interfaces::Chain::Lock& locked_chain) override;
|
||||
struct Balance {
|
||||
CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
|
||||
CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)
|
||||
|
||||
Reference in New Issue
Block a user