From f0395196ec8bbd2b5e01e52dc01bfe5e474e30c0 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 29 Oct 2023 21:45:30 -0400 Subject: [PATCH] Do not resend wallet txs during IBD, rescan or loading blocks --- src/wallet/wallet.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a615d5bdc..3071d46a7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -67,6 +67,7 @@ bool fPayAtLeastCustomFee = true; CBlockIndex *hush_chainactive(int32_t height); extern std::string DONATION_PUBKEY; +extern int32_t HUSH_LOADINGBLOCKS; int32_t hush_dpowconfs(int32_t height,int32_t numconfs); int tx_height( const uint256 &hash ); bool fTxDeleteEnabled = false; @@ -3184,7 +3185,6 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) void CWallet::ResendWalletTransactions(int64_t nBestBlockTime) { - LogPrintf("%s: nBestBlockTime=%ld nNextResend=%ld nLastResend=%ld time=%ld\n", __func__, nBestBlockTime, nNextResend, nLastResend, GetTime()); // Do this infrequently and randomly to avoid giving away // that these are our transactions. if (GetTime() < nNextResend || !fBroadcastTransactions) @@ -3195,11 +3195,26 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime) if (fFirst) return; + // do not resend during IBD/rescan because some txs will be unconfirmed + // until completion + if(IsInitialBlockDownload()) { + return; + } + if (pwalletMain->fRescanning) { + return; + } + + // do not resend during a reindex or initial loading of blocks + if (HUSH_LOADINGBLOCKS) { + return; + } + // Only do it if there's been a new block since last time if (nBestBlockTime < nLastResend) return; nLastResend = GetTime(); + LogPrintf("%s: nBestBlockTime=%ld nNextResend=%ld nLastResend=%ld time=%ld\n", __func__, nBestBlockTime, nNextResend, nLastResend, GetTime()); // Rebroadcast unconfirmed txes older than 5 minutes before the last // block was found: std::vector relayed = ResendWalletTransactionsBefore(nBestBlockTime-5*60);