Skip to content

Commit e191fac

Browse files
committed
Merge bitcoin#25922: wallet: trigger MaybeResendWalletTxs() every minute
5ef8c2c test: fix typo for MaybeResendWalletTxs (stickies-v) fbba4a1 wallet: trigger MaybeResendWalletTxs() every minute (stickies-v) Pull request description: ResendWalletTransactions() only executes every [12-36h (24h average)](https://github.com/bitcoin/bitcoin/blob/1420547ec30a24fc82ba3ae5ac18374e8e5af5e5/src/wallet/wallet.cpp#L1947). Triggering it every second is excessive, once per minute should be plenty. The goal of this PR is to reduce the amount of (unnecessary) schedule executions by ~60x without meaningfully altering transaction rebroadcast logic/assumptions which would require more significant review. ACKs for top commit: achow101: ACK 5ef8c2c 1440000bytes: ACK bitcoin@5ef8c2c Tree-SHA512: 4a077e3579b289c11c347eaa0d3601ef2dbb9fee66ab918d56b4a0c2e08222560a0e6be295297a74831836e001a997ecc143adb0c132faaba96a669dac1cd9e6
2 parents 80da4be + 5ef8c2c commit e191fac

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/wallet/load.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void StartWallets(WalletContext& context, CScheduler& scheduler)
151151
if (context.args->GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) {
152152
scheduler.scheduleEvery([&context] { MaybeCompactWalletDB(context); }, std::chrono::milliseconds{500});
153153
}
154-
scheduler.scheduleEvery([&context] { MaybeResendWalletTxs(context); }, std::chrono::milliseconds{1000});
154+
scheduler.scheduleEvery([&context] { MaybeResendWalletTxs(context); }, 1min);
155155
}
156156

157157
void FlushWallets(WalletContext& context)

test/functional/wallet_resendwallettransactions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def run_test(self):
2929
self.log.info("Create a new transaction and wait until it's broadcast")
3030
txid = node.sendtoaddress(node.getnewaddress(), 1)
3131

32-
# Wallet rebroadcast is first scheduled 1 sec after startup (see
32+
# Wallet rebroadcast is first scheduled 1 min sec after startup (see
3333
# nNextResend in ResendWalletTransactions()). Tell scheduler to call
34-
# MaybeResendWalletTxn now to initialize nNextResend before the first
34+
# MaybeResendWalletTxs now to initialize nNextResend before the first
3535
# setmocktime call below.
36-
node.mockscheduler(1)
36+
node.mockscheduler(60)
3737

3838
# Can take a few seconds due to transaction trickling
3939
peer_first.wait_for_broadcast([txid])
@@ -60,16 +60,16 @@ def run_test(self):
6060
twelve_hrs = 12 * 60 * 60
6161
two_min = 2 * 60
6262
node.setmocktime(now + twelve_hrs - two_min)
63-
node.mockscheduler(1) # Tell scheduler to call MaybeResendWalletTxn now
63+
node.mockscheduler(60) # Tell scheduler to call MaybeResendWalletTxs now
6464
assert_equal(int(txid, 16) in peer_second.get_invs(), False)
6565

6666
self.log.info("Bump time & check that transaction is rebroadcast")
6767
# Transaction should be rebroadcast approximately 24 hours in the future,
6868
# but can range from 12-36. So bump 36 hours to be sure.
6969
with node.assert_debug_log(['ResendWalletTransactions: resubmit 1 unconfirmed transactions']):
7070
node.setmocktime(now + 36 * 60 * 60)
71-
# Tell scheduler to call MaybeResendWalletTxn now.
72-
node.mockscheduler(1)
71+
# Tell scheduler to call MaybeResendWalletTxs now.
72+
node.mockscheduler(60)
7373
# Give some time for trickle to occur
7474
node.setmocktime(now + 36 * 60 * 60 + 600)
7575
peer_second.wait_for_broadcast([txid])

0 commit comments

Comments
 (0)