diff options
author | Andrew Chow <github@achow101.com> | 2022-08-26 16:55:22 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2022-08-26 17:11:17 -0400 |
commit | e191fac4f3c37820f0618f72f0a8e8b524531ab8 (patch) | |
tree | 4837f988feeb0943b12ccedc4c9d3f948d3a6cd9 | |
parent | 80da4be57b05c8b84ca471f975f0f6ca78ade2fd (diff) | |
parent | 5ef8c2c9fc4ebce6cbfea6a55a89a0ab7ee98a1a (diff) |
Merge bitcoin/bitcoin#25922: wallet: trigger MaybeResendWalletTxs() every minute
5ef8c2c9fc4ebce6cbfea6a55a89a0ab7ee98a1a test: fix typo for MaybeResendWalletTxs (stickies-v)
fbba4a131647c991afc53b6a3dfb9721f5c430b2 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 5ef8c2c9fc4ebce6cbfea6a55a89a0ab7ee98a1a
1440000bytes:
ACK https://github.com/bitcoin/bitcoin/pull/25922/commits/5ef8c2c9fc4ebce6cbfea6a55a89a0ab7ee98a1a
Tree-SHA512: 4a077e3579b289c11c347eaa0d3601ef2dbb9fee66ab918d56b4a0c2e08222560a0e6be295297a74831836e001a997ecc143adb0c132faaba96a669dac1cd9e6
-rw-r--r-- | src/wallet/load.cpp | 2 | ||||
-rwxr-xr-x | test/functional/wallet_resendwallettransactions.py | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index c06513588b..6eb0ef5e7a 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -151,7 +151,7 @@ void StartWallets(WalletContext& context, CScheduler& scheduler) if (context.args->GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) { scheduler.scheduleEvery([&context] { MaybeCompactWalletDB(context); }, std::chrono::milliseconds{500}); } - scheduler.scheduleEvery([&context] { MaybeResendWalletTxs(context); }, std::chrono::milliseconds{1000}); + scheduler.scheduleEvery([&context] { MaybeResendWalletTxs(context); }, 1min); } void FlushWallets(WalletContext& context) diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py index 6552bfe60c..4ef259efe1 100755 --- a/test/functional/wallet_resendwallettransactions.py +++ b/test/functional/wallet_resendwallettransactions.py @@ -29,11 +29,11 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): self.log.info("Create a new transaction and wait until it's broadcast") txid = node.sendtoaddress(node.getnewaddress(), 1) - # Wallet rebroadcast is first scheduled 1 sec after startup (see + # Wallet rebroadcast is first scheduled 1 min sec after startup (see # nNextResend in ResendWalletTransactions()). Tell scheduler to call - # MaybeResendWalletTxn now to initialize nNextResend before the first + # MaybeResendWalletTxs now to initialize nNextResend before the first # setmocktime call below. - node.mockscheduler(1) + node.mockscheduler(60) # Can take a few seconds due to transaction trickling peer_first.wait_for_broadcast([txid]) @@ -60,7 +60,7 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): twelve_hrs = 12 * 60 * 60 two_min = 2 * 60 node.setmocktime(now + twelve_hrs - two_min) - node.mockscheduler(1) # Tell scheduler to call MaybeResendWalletTxn now + node.mockscheduler(60) # Tell scheduler to call MaybeResendWalletTxs now assert_equal(int(txid, 16) in peer_second.get_invs(), False) self.log.info("Bump time & check that transaction is rebroadcast") @@ -68,8 +68,8 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): # but can range from 12-36. So bump 36 hours to be sure. with node.assert_debug_log(['ResendWalletTransactions: resubmit 1 unconfirmed transactions']): node.setmocktime(now + 36 * 60 * 60) - # Tell scheduler to call MaybeResendWalletTxn now. - node.mockscheduler(1) + # Tell scheduler to call MaybeResendWalletTxs now. + node.mockscheduler(60) # Give some time for trickle to occur node.setmocktime(now + 36 * 60 * 60 + 600) peer_second.wait_for_broadcast([txid]) |