From 4331c3007b1211998d74a66e908f2de7c82ec564 Mon Sep 17 00:00:00 2001 From: ale Date: Fri, 5 Apr 2024 19:50:39 +0200 Subject: [PATCH] refactor: move nTimeBestReceived to CWallet --- src/net_processing.cpp | 3 --- src/validation.h | 1 - src/wallet/wallet.cpp | 5 +++++ src/wallet/wallet.h | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 166fbca88847b..e55684daf8b62 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -34,7 +34,6 @@ using namespace std::chrono_literals; -int64_t nTimeBestReceived = 0; // Used only to inform the wallet of when we last received a block static const uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; // SHA256("main address relay")[0:8] @@ -757,8 +756,6 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex* pindexNew, const CB } }); } - - nTimeBestReceived = GetTime(); } void PeerLogicValidation::BlockChecked(const CBlock& block, const CValidationState& state) diff --git a/src/validation.h b/src/validation.h index 3fa5710b1833f..f8cdf6d829673 100644 --- a/src/validation.h +++ b/src/validation.h @@ -129,7 +129,6 @@ extern BlockMap mapBlockIndex; extern PrevBlockMap mapPrevBlockIndex; extern uint64_t nLastBlockTx; extern uint64_t nLastBlockSize; -extern int64_t nTimeBestReceived; // Best block section extern Mutex g_best_block_mutex; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 47bfa308ba511..edbfa7b2fea23 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2088,6 +2088,11 @@ void CWallet::ResendWalletTransactions(CConnman* connman) } } +void CWallet::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) +{ + nTimeBestReceived = GetTime(); +} + /** @} */ // end of mapWallet diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index b85b3e287b2fd..85ebfa6de612e 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -628,6 +628,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface int64_t nNextResend; int64_t nLastResend; + int64_t nTimeBestReceived = 0; // Used only to inform the wallet of when we last received a block /** * Used to keep track of spent outpoints, and @@ -1042,6 +1043,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface void TransactionRemovedFromMempool(const CTransactionRef &ptx, MemPoolRemovalReason reason) override; void ReacceptWalletTransactions(bool fFirstLoad = false); void ResendWalletTransactions(CConnman* connman) override; + void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override; struct Balance { CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more