This changes some unchecked std::string
format strings to use string literals, which are consteval
checked at compile-time.
Split out, because it is used in several pull requests.
This changes some unchecked std::string
format strings to use string literals, which are consteval
checked at compile-time.
Split out, because it is used in several pull requests.
Pass literal format strings instead of std::string so formats can be
checked at compile time.
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: stickies-v <stickies-v@protonmail.com>
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31287.
See the guideline for information on the review process.
If your review is incorrectly listed, please react with š to this comment and the bot will ignore it on the next update.
1896@@ -1897,7 +1897,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
1897 fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks");
1898
1899 fAbortRescan = false;
1900- ShowProgress(strprintf("%s " + _("Rescanningā¦").translated, GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
1901+ ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanningā¦").translated), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
0
is another argument to ShowProgress
. AHH.
re: #31287 (review)
I think this confusion only backs up the original comment that:
0ShowProgress(GetDisplayName() + " " + _("Rescanningā¦").translated, 0);
is clearer than:
0ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanningā¦").translated), 0);
code review and light test ACK fa1177e3d7ca9ef003ded4d0c915fa6dc22bd37d
Quick checks:
-printpriority
description with bitcoind -help -help-debug
txrequest_tests
to see the string.tACK fa1177e3d7ca9ef003ded4d0c915fa6dc22bd37d
Make and unit tests successful. Checked the printpriority
arg message in help.
0 -printpriority
1 Log transaction fee rate in BTC/kvB when mining blocks (default: 0)
1911@@ -1912,7 +1912,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
1912 m_scanning_progress = 0;
1913 }
1914 if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) {
1915- ShowProgress(strprintf("%s " + _("Rescanningā¦").translated, GetDisplayName()), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
1916+ ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanningā¦").translated), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
In commit “refactor: Avoid std::string format strings” (fa1177e3d7ca9ef003ded4d0c915fa6dc22bd37d)
Note: Precedes this PR, but there appears to be mixed translation bugs in all the wallet code changed here. GetDisplayName() can return the english string “[default wallet]” while “Rescanning” is translated. This might become a non-issue after the legacy wallet removal where (I’m assuming) unnamed wallets will finally get names? I think having more type safety to make it harder to accidentally combine translated and untranslated strings would be good thing in general, though.
Maybe a follow-up can fix this, so that this remains a refactor?
Thanks, I experimented with various ways to clean up this show progress code, and I think it would probably be best if the string formatting was done in the GUI. This would require interface class changes we probably want anyway, but would be a bigger change. For now just went with a simple bugfix translating “default wallet” to match the rest of the string in #31296
Code review ACK fa1177e3d7ca9ef003ded4d0c915fa6dc22bd37d
I think I’ll merge this PR shortly so we can make progress on related PRs #31061 and #31072, but you can let me know if you would prefer this not to be merged now in case you want to address the comment that using strprintf("%s %s", ...)
instead of +
makes code more confusing