aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2020-01-29 08:21:02 -0800
committerAmiti Uttarwar <amiti@uttarwar.org>2020-04-23 14:42:25 -0700
commitdc1da48dc5e5526215561311c184a8cbc345ecdc (patch)
tree356652687f4ae7d122a7d2d63a8d4ade6a0448f5
parente25e42f20a3aa39651fbc1f9fa3df1a49f1f5868 (diff)
downloadbitcoin-dc1da48dc5e5526215561311c184a8cbc345ecdc.tar.xz
[wallet] Update the rebroadcast frequency to be ~1/day.
Since the mempool unbroadcast mechanism handles the reattempts for initial broadcast, the wallet rebroadcast attempts can be much less frequent (previously ~1/30 min)
-rw-r--r--src/wallet/wallet.cpp3
-rwxr-xr-xtest/functional/wallet_resendwallettransactions.py7
2 files changed, 6 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 9a972febab..6eee0ccfc6 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1978,7 +1978,8 @@ void CWallet::ResendWalletTransactions()
// that these are our transactions.
if (GetTime() < nNextResend || !fBroadcastTransactions) return;
bool fFirst = (nNextResend == 0);
- nNextResend = GetTime() + GetRand(30 * 60);
+ // resend 12-36 hours from now, ~1 day on average.
+ nNextResend = GetTime() + (12 * 60 * 60) + GetRand(24 * 60 * 60);
if (fFirst) return;
// Only do it if there's been a new block since last time
diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py
index d122e3db52..bb12212b59 100755
--- a/test/functional/wallet_resendwallettransactions.py
+++ b/test/functional/wallet_resendwallettransactions.py
@@ -69,9 +69,10 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
node.p2ps[1].sync_with_ping()
assert_equal(node.p2ps[1].tx_invs_received[txid], 0)
- self.log.info("Transaction should be rebroadcast after 30 minutes")
- # Use mocktime and give an extra 5 minutes to be sure.
- rebroadcast_time = int(time.time()) + 41 * 60
+ self.log.info("Bump time & check that transaction is rebroadcast")
+ # Transaction should be rebroadcast approximately 24 hours in the future,
+ # but can range from 12-36. So bump 36 hours to be sure.
+ rebroadcast_time = int(time.time()) + 36 * 60 * 60
node.setmocktime(rebroadcast_time)
wait_until(lambda: node.p2ps[1].tx_invs_received[txid] >= 1, lock=mininode_lock)