Skip to content

Commit d1ae7c0

Browse files
committed
Make GetWarnings() return bilingual_str
1 parent 38e33aa commit d1ae7c0

File tree

10 files changed

+22
-15
lines changed

10 files changed

+22
-15
lines changed

src/interfaces/node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class NodeImpl : public Node
7171
std::string getNetwork() override { return Params().NetworkIDString(); }
7272
void initLogging() override { InitLogging(); }
7373
void initParameterInteraction() override { InitParameterInteraction(); }
74-
std::string getWarnings() override { return GetWarnings(true); }
74+
bilingual_str getWarnings() override { return GetWarnings(true); }
7575
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
7676
bool baseInitialize() override
7777
{

src/interfaces/node.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <net_types.h> // For banmap_t
1111
#include <netaddress.h> // For Network
1212
#include <support/allocators/secure.h> // For SecureString
13+
#include <util/translation.h>
1314

1415
#include <functional>
1516
#include <memory>
@@ -81,7 +82,7 @@ class Node
8182
virtual void initParameterInteraction() = 0;
8283

8384
//! Get warnings.
84-
virtual std::string getWarnings() = 0;
85+
virtual bilingual_str getWarnings() = 0;
8586

8687
// Get log flags.
8788
virtual uint32_t getLogCategories() = 0;

src/qt/bitcoin.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ BitcoinCore::BitcoinCore(interfaces::Node& node) :
155155
void BitcoinCore::handleRunawayException(const std::exception *e)
156156
{
157157
PrintExceptionContinue(e, "Runaway exception");
158-
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings()));
158+
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));
159159
}
160160

161161
void BitcoinCore::initialize()
@@ -599,10 +599,10 @@ int GuiMain(int argc, char* argv[])
599599
}
600600
} catch (const std::exception& e) {
601601
PrintExceptionContinue(&e, "Runaway exception");
602-
app.handleRunawayException(QString::fromStdString(node->getWarnings()));
602+
app.handleRunawayException(QString::fromStdString(node->getWarnings().translated));
603603
} catch (...) {
604604
PrintExceptionContinue(nullptr, "Runaway exception");
605-
app.handleRunawayException(QString::fromStdString(node->getWarnings()));
605+
app.handleRunawayException(QString::fromStdString(node->getWarnings().translated));
606606
}
607607
return rv;
608608
}

src/qt/clientmodel.cpp

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

167167
QString ClientModel::getStatusBarWarnings() const
168168
{
169-
return QString::fromStdString(m_node.getWarnings());
169+
return QString::fromStdString(m_node.getWarnings().translated);
170170
}
171171

172172
OptionsModel *ClientModel::getOptionsModel()

src/rpc/blockchain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <util/ref.h>
3333
#include <util/strencodings.h>
3434
#include <util/system.h>
35+
#include <util/translation.h>
3536
#include <validation.h>
3637
#include <validationinterface.h>
3738
#include <warnings.h>
@@ -1278,7 +1279,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
12781279
BIP9SoftForkDescPushBack(softforks, "testdummy", consensusParams, Consensus::DEPLOYMENT_TESTDUMMY);
12791280
obj.pushKV("softforks", softforks);
12801281

1281-
obj.pushKV("warnings", GetWarnings(false));
1282+
obj.pushKV("warnings", GetWarnings(false).original);
12821283
return obj;
12831284
}
12841285

src/rpc/mining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <util/strencodings.h>
3030
#include <util/string.h>
3131
#include <util/system.h>
32+
#include <util/translation.h>
3233
#include <validation.h>
3334
#include <validationinterface.h>
3435
#include <versionbitsinfo.h>
@@ -416,7 +417,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
416417
obj.pushKV("networkhashps", getnetworkhashps(request));
417418
obj.pushKV("pooledtx", (uint64_t)mempool.size());
418419
obj.pushKV("chain", Params().NetworkIDString());
419-
obj.pushKV("warnings", GetWarnings(false));
420+
obj.pushKV("warnings", GetWarnings(false).original);
420421
return obj;
421422
}
422423

src/rpc/net.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <util/strencodings.h>
2323
#include <util/string.h>
2424
#include <util/system.h>
25+
#include <util/translation.h>
2526
#include <validation.h>
2627
#include <version.h>
2728
#include <warnings.h>
@@ -548,7 +549,7 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
548549
}
549550
}
550551
obj.pushKV("localaddresses", localAddresses);
551-
obj.pushKV("warnings", GetWarnings(false));
552+
obj.pushKV("warnings", GetWarnings(false).original);
552553
return obj;
553554
}
554555

src/test/timedata_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <test/util/setup_common.h>
1010
#include <timedata.h>
1111
#include <util/string.h>
12+
#include <util/translation.h>
1213
#include <warnings.h>
1314

1415
#include <string>
@@ -66,7 +67,7 @@ BOOST_AUTO_TEST_CASE(addtimedata)
6667
MultiAddTimeData(1, DEFAULT_MAX_TIME_ADJUSTMENT + 1); //filter size 5
6768
}
6869

69-
BOOST_CHECK(GetWarnings(true).find("clock is wrong") != std::string::npos);
70+
BOOST_CHECK(GetWarnings(true).original.find("clock is wrong") != std::string::npos);
7071

7172
// nTimeOffset is not changed if the median of offsets exceeds DEFAULT_MAX_TIME_ADJUSTMENT
7273
BOOST_CHECK_EQUAL(GetTimeOffset(), 0);

src/warnings.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void SetfLargeWorkInvalidChainFound(bool flag)
4141
fLargeWorkInvalidChainFound = flag;
4242
}
4343

44-
std::string GetWarnings(bool verbose)
44+
bilingual_str GetWarnings(bool verbose)
4545
{
4646
bilingual_str warnings_concise;
4747
std::vector<bilingual_str> warnings_verbose;
@@ -69,8 +69,8 @@ std::string GetWarnings(bool verbose)
6969
}
7070

7171
if (verbose) {
72-
return Join(warnings_verbose, Untranslated("<hr />")).translated;
72+
return Join(warnings_verbose, Untranslated("<hr />"));
7373
}
7474

75-
return warnings_concise.original;
75+
return warnings_concise;
7676
}

src/warnings.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88

99
#include <string>
1010

11+
struct bilingual_str;
12+
1113
void SetMiscWarning(const std::string& strWarning);
1214
void SetfLargeWorkForkFound(bool flag);
1315
bool GetfLargeWorkForkFound();
1416
void SetfLargeWorkInvalidChainFound(bool flag);
1517
/** Format a string that describes several potential problems detected by the core.
1618
* @param[in] verbose bool
17-
* - if true, get all warnings, translated (where possible), separated by <hr />
19+
* - if true, get all warnings separated by <hr />
1820
* - if false, get the most important warning
1921
* @returns the warning string
2022
*/
21-
std::string GetWarnings(bool verbose);
23+
bilingual_str GetWarnings(bool verbose);
2224

2325
#endif // BITCOIN_WARNINGS_H

0 commit comments

Comments
 (0)