Make GetWarnings() return bilingual_str
This commit is contained in:
10 files changed
+22
-15
No files matched your search
@@ -71,7 +71,7 @@ public:
|
|||||||
std::string getNetwork() override { return Params().NetworkIDString(); }
|
std::string getNetwork() override { return Params().NetworkIDString(); }
|
||||||
void initLogging() override { InitLogging(); }
|
void initLogging() override { InitLogging(); }
|
||||||
void initParameterInteraction() override { InitParameterInteraction(); }
|
void initParameterInteraction() override { InitParameterInteraction(); }
|
||||||
std::string getWarnings() override { return GetWarnings(true); }
|
bilingual_str getWarnings() override { return GetWarnings(true); }
|
||||||
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
|
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
|
||||||
bool baseInitialize() override
|
bool baseInitialize() override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <net_types.h> // For banmap_t
|
#include <net_types.h> // For banmap_t
|
||||||
#include <netaddress.h> // For Network
|
#include <netaddress.h> // For Network
|
||||||
#include <support/allocators/secure.h> // For SecureString
|
#include <support/allocators/secure.h> // For SecureString
|
||||||
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -81,7 +82,7 @@ public:
|
|||||||
virtual void initParameterInteraction() = 0;
|
virtual void initParameterInteraction() = 0;
|
||||||
|
|
||||||
//! Get warnings.
|
//! Get warnings.
|
||||||
virtual std::string getWarnings() = 0;
|
virtual bilingual_str getWarnings() = 0;
|
||||||
|
|
||||||
// Get log flags.
|
// Get log flags.
|
||||||
virtual uint32_t getLogCategories() = 0;
|
virtual uint32_t getLogCategories() = 0;
|
||||||
|
|||||||
+3
-3
@@ -155,7 +155,7 @@ BitcoinCore::BitcoinCore(interfaces::Node& node) :
|
|||||||
void BitcoinCore::handleRunawayException(const std::exception *e)
|
void BitcoinCore::handleRunawayException(const std::exception *e)
|
||||||
{
|
{
|
||||||
PrintExceptionContinue(e, "Runaway exception");
|
PrintExceptionContinue(e, "Runaway exception");
|
||||||
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings()));
|
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinCore::initialize()
|
void BitcoinCore::initialize()
|
||||||
@@ -599,10 +599,10 @@ int GuiMain(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
PrintExceptionContinue(&e, "Runaway exception");
|
PrintExceptionContinue(&e, "Runaway exception");
|
||||||
app.handleRunawayException(QString::fromStdString(node->getWarnings()));
|
app.handleRunawayException(QString::fromStdString(node->getWarnings().translated));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
PrintExceptionContinue(nullptr, "Runaway exception");
|
PrintExceptionContinue(nullptr, "Runaway exception");
|
||||||
app.handleRunawayException(QString::fromStdString(node->getWarnings()));
|
app.handleRunawayException(QString::fromStdString(node->getWarnings().translated));
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ enum BlockSource ClientModel::getBlockSource() const
|
|||||||
|
|
||||||
QString ClientModel::getStatusBarWarnings() const
|
QString ClientModel::getStatusBarWarnings() const
|
||||||
{
|
{
|
||||||
return QString::fromStdString(m_node.getWarnings());
|
return QString::fromStdString(m_node.getWarnings().translated);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsModel *ClientModel::getOptionsModel()
|
OptionsModel *ClientModel::getOptionsModel()
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <util/ref.h>
|
#include <util/ref.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
#include <util/translation.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <warnings.h>
|
#include <warnings.h>
|
||||||
@@ -1278,7 +1279,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
|
|||||||
BIP9SoftForkDescPushBack(softforks, "testdummy", consensusParams, Consensus::DEPLOYMENT_TESTDUMMY);
|
BIP9SoftForkDescPushBack(softforks, "testdummy", consensusParams, Consensus::DEPLOYMENT_TESTDUMMY);
|
||||||
obj.pushKV("softforks", softforks);
|
obj.pushKV("softforks", softforks);
|
||||||
|
|
||||||
obj.pushKV("warnings", GetWarnings(false));
|
obj.pushKV("warnings", GetWarnings(false).original);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -29,6 +29,7 @@
|
|||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
#include <util/translation.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <versionbitsinfo.h>
|
#include <versionbitsinfo.h>
|
||||||
@@ -416,7 +417,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
|
|||||||
obj.pushKV("networkhashps", getnetworkhashps(request));
|
obj.pushKV("networkhashps", getnetworkhashps(request));
|
||||||
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
||||||
obj.pushKV("chain", Params().NetworkIDString());
|
obj.pushKV("chain", Params().NetworkIDString());
|
||||||
obj.pushKV("warnings", GetWarnings(false));
|
obj.pushKV("warnings", GetWarnings(false).original);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -22,6 +22,7 @@
|
|||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
#include <util/translation.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
#include <warnings.h>
|
#include <warnings.h>
|
||||||
@@ -548,7 +549,7 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj.pushKV("localaddresses", localAddresses);
|
obj.pushKV("localaddresses", localAddresses);
|
||||||
obj.pushKV("warnings", GetWarnings(false));
|
obj.pushKV("warnings", GetWarnings(false).original);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <timedata.h>
|
#include <timedata.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
#include <util/translation.h>
|
||||||
#include <warnings.h>
|
#include <warnings.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -66,7 +67,7 @@ BOOST_AUTO_TEST_CASE(addtimedata)
|
|||||||
MultiAddTimeData(1, DEFAULT_MAX_TIME_ADJUSTMENT + 1); //filter size 5
|
MultiAddTimeData(1, DEFAULT_MAX_TIME_ADJUSTMENT + 1); //filter size 5
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK(GetWarnings(true).find("clock is wrong") != std::string::npos);
|
BOOST_CHECK(GetWarnings(true).original.find("clock is wrong") != std::string::npos);
|
||||||
|
|
||||||
// nTimeOffset is not changed if the median of offsets exceeds DEFAULT_MAX_TIME_ADJUSTMENT
|
// nTimeOffset is not changed if the median of offsets exceeds DEFAULT_MAX_TIME_ADJUSTMENT
|
||||||
BOOST_CHECK_EQUAL(GetTimeOffset(), 0);
|
BOOST_CHECK_EQUAL(GetTimeOffset(), 0);
|
||||||
|
|||||||
+3
-3
@@ -41,7 +41,7 @@ void SetfLargeWorkInvalidChainFound(bool flag)
|
|||||||
fLargeWorkInvalidChainFound = flag;
|
fLargeWorkInvalidChainFound = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetWarnings(bool verbose)
|
bilingual_str GetWarnings(bool verbose)
|
||||||
{
|
{
|
||||||
bilingual_str warnings_concise;
|
bilingual_str warnings_concise;
|
||||||
std::vector<bilingual_str> warnings_verbose;
|
std::vector<bilingual_str> warnings_verbose;
|
||||||
@@ -69,8 +69,8 @@ std::string GetWarnings(bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
return Join(warnings_verbose, Untranslated("<hr />")).translated;
|
return Join(warnings_verbose, Untranslated("<hr />"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return warnings_concise.original;
|
return warnings_concise;
|
||||||
}
|
}
|
||||||
+4
-2
@@ -8,16 +8,18 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
struct bilingual_str;
|
||||||
|
|
||||||
void SetMiscWarning(const std::string& strWarning);
|
void SetMiscWarning(const std::string& strWarning);
|
||||||
void SetfLargeWorkForkFound(bool flag);
|
void SetfLargeWorkForkFound(bool flag);
|
||||||
bool GetfLargeWorkForkFound();
|
bool GetfLargeWorkForkFound();
|
||||||
void SetfLargeWorkInvalidChainFound(bool flag);
|
void SetfLargeWorkInvalidChainFound(bool flag);
|
||||||
/** Format a string that describes several potential problems detected by the core.
|
/** Format a string that describes several potential problems detected by the core.
|
||||||
* @param[in] verbose bool
|
* @param[in] verbose bool
|
||||||
* - if true, get all warnings, translated (where possible), separated by <hr />
|
* - if true, get all warnings separated by <hr />
|
||||||
* - if false, get the most important warning
|
* - if false, get the most important warning
|
||||||
* @returns the warning string
|
* @returns the warning string
|
||||||
*/
|
*/
|
||||||
std::string GetWarnings(bool verbose);
|
bilingual_str GetWarnings(bool verbose);
|
||||||
|
|
||||||
#endif // BITCOIN_WARNINGS_H
|
#endif // BITCOIN_WARNINGS_H
|
||||||
Reference in new issue
Block a user