-
Notifications
You must be signed in to change notification settings - Fork 38.1k
add (none)
in -getinfo Warnings:
if no warning returned
#24632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK 1249aa6
Confirmed Warning is being thrown even if there are no Warnings
The version is showing 220000 I think because of the version of bitcoind im running, I could be wrong though.
Blocks: 728446
Headers: 728446
Verification progress: 99.9998%
Difficulty: 27452707696466.39
Network: in 8, out 10, total 18
Version: 220000
Time offset (s): 0
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000
Warnings:
Compiled and tested fix with no issues with the desired outcome of not throwing empty warnings.
Chain: main
Blocks: 728448
Headers: 728448
Verification progress: 99.9999%
Difficulty: 27452707696466.39
Network: in 15, out 10, total 25
Version: 220000
Time offset (s): 0
Proxies: n/a
Min tx relay fee rate (BTC/kvB): 0.00001000
@jessebarton I see |
src/bitcoin-cli.cpp
Outdated
if (result["warnings"].getValStr()!="") | ||
{ | ||
result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, result["warnings"].getValStr()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestions
- don't add extra line breaks when no warning is present
- avoid running getValStr() twice
- use empty()
- clang-format of brackets in the conditional
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -1038,7 +1038,7 @@ static void ParseGetInfoResult(UniValue& result)
result_string += strprintf("Transaction fee rate (-paytxfee) (%s/kvB): %s\n\n", CURRENCY_UNIT, result["paytxfee"].getValStr());
}
if (!result["balance"].isNull()) {
- result_string += strprintf("%sBalance:%s %s\n\n", CYAN, RESET, result["balance"].getValStr());
+ result_string += strprintf("%sBalance:%s %s\n", CYAN, RESET, result["balance"].getValStr());
}
if (!result["balances"].isNull()) {
@@ -1056,13 +1056,13 @@ static void ParseGetInfoResult(UniValue& result)
result["balances"][wallet].getValStr(),
wallet.empty() ? "\"\"" : wallet);
}
- result_string += "\n";
}
- if (result["warnings"].getValStr()!="")
- {
- result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, result["warnings"].getValStr());
+ const std::string warnings{result["warnings"].getValStr()};
+ if (!warnings.empty()) {
+ result_string += strprintf("\n%sWarnings:%s %s", YELLOW, RESET, warnings);
}
+
result.setStr(result_string);
}
With this suggestion, I think there is still an extra line break after the balance/balances, if you can look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonatack thanks for review and suggestion. Made changes, tested and it looks good. Let me know if there are any issues with line breaks:
With warning: https://pastebin.com/raw/eN3SGjiX
Without warning: https://pastebin.com/raw/frfnqfvU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned, there is still an extra line, and the commits should be squashed, as the extra line is created by the changes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Removed extra lines: https://pastebin.com/raw/bZk4YNj5 and squashed commits.
Concept ACK. Previously, -getinfo returned a JSON-RPC-like response with the "warnings" field returned by getnetworkinfo after calling |
Thanks for updating.
|
Concept ACK |
Sorry, missed this. Will do it this weekend.
Done |
Warnings:
only if warning returnedWarnings:
only if warning returned
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
I don't know about leaving it out entirely. It might be reassuring to the user that there are, explicitly, no warnings. Or less reassuring (but important) that there could be warnings, but are none. Could format it different like |
Good point (and probably a simpler change to implement). |
Warnings:
only if warning returned(none)
in -getinfo Warnings:
if no warning returned
Done in last commit. Updated pull request title and description. |
src/bitcoin-cli.cpp
Outdated
result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, result["warnings"].getValStr()); | ||
const std::string warnings{result["warnings"].getValStr()}; | ||
if (warnings.empty()) { | ||
result_string += strprintf("%sWarnings: %s(none)", YELLOW, RESET); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result_string += strprintf("%sWarnings: %s(none)", YELLOW, RESET); | |
result_string += strprintf("%sWarnings:%s (none)", YELLOW, RESET); |
alternatively, could simplify
- if (warnings.empty()) {
- result_string += strprintf("%sWarnings: %s(none)", YELLOW, RESET);
- } else {
- result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, warnings);
- }
+ result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, warnings.empty() ? "(none)" : warnings);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in last commit.
ACK 0cea7b1 |
Tested ACK 0cea7b1 |
…ng returned 0cea7b1 print `(none)` if no warnings in -getinfo (/dev/fd0) Pull request description: Adds `(none)` in warnings when no warnings returned by -getinfo Reviewers can test this by making the following change in `/src/warnings.cpp`: ```diff bilingual_str GetWarnings(bool verbose) { bilingual_str warnings_concise; std::vector<bilingual_str> warnings_verbose; LOCK(g_warnings_mutex); // Pre-release build warning if (!CLIENT_VERSION_IS_RELEASE) { - warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");; + warnings_concise = _("");; ``` Before this pull request: ``` $ bitcoin-cli -getinfo Chain: regtest Blocks: 0 Headers: 0 Verification progress: 100.0000% Difficulty: 4.656542373906925e-10 Network: in 0, out 0, total 0 Version: 239900 Time offset (s): 0 Proxies: n/a Min tx relay fee rate (BTC/kvB): 0.00001000 Warnings: ``` After this pull request: ```diff $ bitcoin-cli -getinfo Chain: regtest Blocks: 0 Headers: 0 Verification progress: 100.0000% Difficulty: 4.656542373906925e-10 Network: in 0, out 0, total 0 Version: 239900 Time offset (s): 0 Proxies: n/a Min tx relay fee rate (BTC/kvB): 0.00001000 Warnings: (none) ``` ACKs for top commit: jonatack: ACK 0cea7b1 laanwj: Tested ACK 0cea7b1 Tree-SHA512: a12499d11ff84bc954db354f968eb1f5ee4999d8b80581fe0bdf604732b2e2f608cb5c35c4ca8cb5a430f3991954a6207f0758302618662e6b9505044cf2dc95
Adds
(none)
in warnings when no warnings returned by -getinfoReviewers can test this by making the following change in
/src/warnings.cpp
:Before this pull request:
After this pull request: