Skip to content

Commit c0c08c7

Browse files
committed
Merge pull request #7141
aabc897 rpc: Don't translate warning messages (Wladimir J. van der Laan)
2 parents a60538b + aabc897 commit c0c08c7

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/main.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3990,29 +3990,34 @@ std::string GetWarnings(const std::string& strFor)
39903990
int nPriority = 0;
39913991
string strStatusBar;
39923992
string strRPC;
3993+
string strGUI;
39933994

3994-
if (!CLIENT_VERSION_IS_RELEASE)
3995-
strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
3995+
if (!CLIENT_VERSION_IS_RELEASE) {
3996+
strStatusBar = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
3997+
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
3998+
}
39963999

39974000
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
3998-
strStatusBar = strRPC = "testsafemode enabled";
4001+
strStatusBar = strRPC = strGUI = "testsafemode enabled";
39994002

40004003
// Misc warnings like out of disk space and clock is wrong
40014004
if (strMiscWarning != "")
40024005
{
40034006
nPriority = 1000;
4004-
strStatusBar = strMiscWarning;
4007+
strStatusBar = strGUI = strMiscWarning;
40054008
}
40064009

40074010
if (fLargeWorkForkFound)
40084011
{
40094012
nPriority = 2000;
4010-
strStatusBar = strRPC = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
4013+
strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
4014+
strGUI = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
40114015
}
40124016
else if (fLargeWorkInvalidChainFound)
40134017
{
40144018
nPriority = 2000;
4015-
strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
4019+
strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
4020+
strGUI = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
40164021
}
40174022

40184023
// Alerts
@@ -4024,12 +4029,14 @@ std::string GetWarnings(const std::string& strFor)
40244029
if (alert.AppliesToMe() && alert.nPriority > nPriority)
40254030
{
40264031
nPriority = alert.nPriority;
4027-
strStatusBar = alert.strStatusBar;
4032+
strStatusBar = strGUI = alert.strStatusBar;
40284033
}
40294034
}
40304035
}
40314036

4032-
if (strFor == "statusbar")
4037+
if (strFor == "gui")
4038+
return strGUI;
4039+
else if (strFor == "statusbar")
40334040
return strStatusBar;
40344041
else if (strFor == "rpc")
40354042
return strRPC;

src/main.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ void ThreadScriptCheck();
206206
void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader, int64_t nPowTargetSpacing);
207207
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
208208
bool IsInitialBlockDownload();
209-
/** Format a string that describes several potential problems detected by the core */
209+
/** Format a string that describes several potential problems detected by the core.
210+
* strFor can have three values:
211+
* - "rpc": get critical warnings, which should put the client in safe mode if non-empty
212+
* - "statusbar": get all warnings
213+
* - "gui": get all warnings, translated (where possible) for GUI
214+
* This function only returns the highest priority warning of the set selected by strFor.
215+
*/
210216
std::string GetWarnings(const std::string& strFor);
211217
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
212218
bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false);

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ enum BlockSource ClientModel::getBlockSource() const
158158

159159
QString ClientModel::getStatusBarWarnings() const
160160
{
161-
return QString::fromStdString(GetWarnings("statusbar"));
161+
return QString::fromStdString(GetWarnings("gui"));
162162
}
163163

164164
OptionsModel *ClientModel::getOptionsModel()

0 commit comments

Comments
 (0)