Skip to content

Commit fa1177e

Browse files
MarcoFalkeryanofskystickies-v
committed
refactor: Avoid std::string format strings
Pass literal format strings instead of std::string so formats can be checked at compile time. Co-authored-by: Ryan Ofsky <[email protected]> Co-authored-by: stickies-v <[email protected]>
1 parent e546b4e commit fa1177e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/init.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
621621
strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)",
622622
Ticks<std::chrono::seconds>(DEFAULT_MAX_TIP_AGE)),
623623
ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
624-
argsman.AddArg("-printpriority", strprintf("Log transaction fee rate in " + CURRENCY_UNIT + "/kvB when mining blocks (default: %u)", DEFAULT_PRINT_MODIFIED_FEE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
624+
argsman.AddArg("-printpriority", strprintf("Log transaction fee rate in %s/kvB when mining blocks (default: %u)", CURRENCY_UNIT, DEFAULT_PRINT_MODIFIED_FEE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
625625
argsman.AddArg("-uacomment=<cmt>", "Append comment to the user agent string", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
626626

627627
SetupChainParamsBaseOptions(argsman);

src/test/txrequest_tests.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ class Scenario
178178
size_t real_total = runner.txrequest.Count(peer);
179179
size_t real_candidates = runner.txrequest.CountCandidates(peer);
180180
size_t real_inflight = runner.txrequest.CountInFlight(peer);
181-
BOOST_CHECK_MESSAGE(real_total == total, strprintf("[" + comment + "] total %i (%i expected)", real_total, total));
182-
BOOST_CHECK_MESSAGE(real_inflight == inflight, strprintf("[" + comment + "] inflight %i (%i expected)", real_inflight, inflight));
183-
BOOST_CHECK_MESSAGE(real_candidates == candidates, strprintf("[" + comment + "] candidates %i (%i expected)", real_candidates, candidates));
184-
BOOST_CHECK_MESSAGE(ret == expected, "[" + comment + "] mismatching requestables");
181+
BOOST_CHECK_MESSAGE(real_total == total, strprintf("[%s] total %i (%i expected)", comment, real_total, total));
182+
BOOST_CHECK_MESSAGE(real_inflight == inflight, strprintf("[%s] inflight %i (%i expected)", comment, real_inflight, inflight));
183+
BOOST_CHECK_MESSAGE(real_candidates == candidates, strprintf("[%s] candidates %i (%i expected)", comment, real_candidates, candidates));
184+
BOOST_CHECK_MESSAGE(ret == expected, strprintf("[%s] mismatching requestables", comment));
185185
});
186186
}
187187

src/wallet/rpc/backup.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ RPCHelpMan importwallet()
534534

535535
// Use uiInterface.ShowProgress instead of pwallet.ShowProgress because pwallet.ShowProgress has a cancel button tied to AbortRescan which
536536
// we don't want for this progress bar showing the import progress. uiInterface.ShowProgress does not have a cancel button.
537-
pwallet->chain().showProgress(strprintf("%s " + _("Importing…").translated, pwallet->GetDisplayName()), 0, false); // show progress dialog in GUI
537+
pwallet->chain().showProgress(strprintf("%s %s", pwallet->GetDisplayName(), _("Importing…").translated), 0, false); // show progress dialog in GUI
538538
std::vector<std::tuple<CKey, int64_t, bool, std::string>> keys;
539539
std::vector<std::pair<CScript, int64_t>> scripts;
540540
while (file.good()) {

src/wallet/wallet.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
18971897
fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks");
18981898

18991899
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)
1900+
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)
19011901
uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash());
19021902
uint256 end_hash = tip_hash;
19031903
if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash));
@@ -1912,7 +1912,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
19121912
m_scanning_progress = 0;
19131913
}
19141914
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))));
1915+
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…").translated), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
19161916
}
19171917

19181918
bool next_interval = reserver.now() >= current_time + INTERVAL_TIME;
@@ -2009,7 +2009,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
20092009
WalletLogPrintf("Scanning current mempool transactions.\n");
20102010
WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this));
20112011
}
2012-
ShowProgress(strprintf("%s " + _("Rescanning…").translated, GetDisplayName()), 100); // hide progress dialog in GUI
2012+
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…").translated), 100); // hide progress dialog in GUI
20132013
if (block_height && fAbortRescan) {
20142014
WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height, progress_current);
20152015
result.status = ScanResult::USER_ABORT;

0 commit comments

Comments
 (0)