aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am4
-rw-r--r--src/index/base.cpp1
-rw-r--r--src/node/abort.cpp2
-rw-r--r--src/node/interfaces.cpp2
-rw-r--r--src/node/kernel_notifications.cpp4
-rw-r--r--src/node/timeoffsets.cpp6
-rw-r--r--src/node/warnings.cpp (renamed from src/warnings.cpp)19
-rw-r--r--src/node/warnings.h (renamed from src/warnings.h)15
-rw-r--r--src/rpc/blockchain.cpp3
-rw-r--r--src/rpc/mining.cpp3
-rw-r--r--src/rpc/net.cpp3
-rw-r--r--src/rpc/util.cpp19
-rw-r--r--src/rpc/util.h2
-rw-r--r--src/validation.cpp6
14 files changed, 50 insertions, 39 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2562c4cc65..77e0c3a6da 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -239,6 +239,7 @@ BITCOIN_CORE_H = \
node/types.h \
node/utxo_snapshot.h \
node/validation_cache_args.h \
+ node/warnings.h \
noui.h \
outputtype.h \
policy/v3_policy.h \
@@ -367,7 +368,6 @@ BITCOIN_CORE_H = \
wallet/wallettool.h \
wallet/walletutil.h \
walletinitinterface.h \
- warnings.h \
zmq/zmqabstractnotifier.h \
zmq/zmqnotificationinterface.h \
zmq/zmqpublishnotifier.h \
@@ -444,6 +444,7 @@ libbitcoin_node_a_SOURCES = \
node/txreconciliation.cpp \
node/utxo_snapshot.cpp \
node/validation_cache_args.cpp \
+ node/warnings.cpp \
noui.cpp \
policy/v3_policy.cpp \
policy/fees.cpp \
@@ -721,7 +722,6 @@ libbitcoin_common_a_SOURCES = \
script/sign.cpp \
script/signingprovider.cpp \
script/solver.cpp \
- warnings.cpp \
$(BITCOIN_CORE_H)
#
diff --git a/src/index/base.cpp b/src/index/base.cpp
index e66c89f9e4..c222fd22fc 100644
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -17,7 +17,6 @@
#include <util/thread.h>
#include <util/translation.h>
#include <validation.h> // For g_chainman
-#include <warnings.h>
#include <string>
#include <utility>
diff --git a/src/node/abort.cpp b/src/node/abort.cpp
index b727608384..6f836824b2 100644
--- a/src/node/abort.cpp
+++ b/src/node/abort.cpp
@@ -6,9 +6,9 @@
#include <logging.h>
#include <node/interface_ui.h>
+#include <node/warnings.h>
#include <util/signalinterrupt.h>
#include <util/translation.h>
-#include <warnings.h>
#include <atomic>
#include <cstdlib>
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 19f4aaf9c4..88af9dadbc 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -32,6 +32,7 @@
#include <node/mini_miner.h>
#include <node/transaction.h>
#include <node/types.h>
+#include <node/warnings.h>
#include <policy/feerate.h>
#include <policy/fees.h>
#include <policy/policy.h>
@@ -53,7 +54,6 @@
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
-#include <warnings.h>
#include <config/bitcoin-config.h> // IWYU pragma: keep
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp
index 1f07014ee2..1900ac3117 100644
--- a/src/node/kernel_notifications.cpp
+++ b/src/node/kernel_notifications.cpp
@@ -13,12 +13,12 @@
#include <logging.h>
#include <node/abort.h>
#include <node/interface_ui.h>
+#include <node/warnings.h>
#include <util/check.h>
#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
-#include <warnings.h>
#include <cstdint>
#include <string>
@@ -49,7 +49,7 @@ static void AlertNotify(const std::string& strMessage)
static void DoWarning(const bilingual_str& warning)
{
static bool fWarned = false;
- SetMiscWarning(warning);
+ node::SetMiscWarning(warning);
if (!fWarned) {
AlertNotify(warning.original);
fWarned = true;
diff --git a/src/node/timeoffsets.cpp b/src/node/timeoffsets.cpp
index 62f527be8a..17ee44a92c 100644
--- a/src/node/timeoffsets.cpp
+++ b/src/node/timeoffsets.cpp
@@ -5,11 +5,11 @@
#include <logging.h>
#include <node/interface_ui.h>
#include <node/timeoffsets.h>
+#include <node/warnings.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/time.h>
#include <util/translation.h>
-#include <warnings.h>
#include <algorithm>
#include <chrono>
@@ -49,7 +49,7 @@ bool TimeOffsets::WarnIfOutOfSync() const
// when median == std::numeric_limits<int64_t>::min(), calling std::chrono::abs is UB
auto median{std::max(Median(), std::chrono::seconds(std::numeric_limits<int64_t>::min() + 1))};
if (std::chrono::abs(median) <= WARN_THRESHOLD) {
- SetMedianTimeOffsetWarning(std::nullopt);
+ node::SetMedianTimeOffsetWarning(std::nullopt);
uiInterface.NotifyAlertChanged();
return false;
}
@@ -63,7 +63,7 @@ bool TimeOffsets::WarnIfOutOfSync() const
"RPC methods to get more info."
), Ticks<std::chrono::minutes>(WARN_THRESHOLD))};
LogWarning("%s\n", msg.original);
- SetMedianTimeOffsetWarning(msg);
+ node::SetMedianTimeOffsetWarning(msg);
uiInterface.NotifyAlertChanged();
return true;
}
diff --git a/src/warnings.cpp b/src/node/warnings.cpp
index 38c0554cf2..9d2239e64a 100644
--- a/src/warnings.cpp
+++ b/src/node/warnings.cpp
@@ -5,10 +5,11 @@
#include <config/bitcoin-config.h> // IWYU pragma: keep
-#include <warnings.h>
+#include <node/warnings.h>
#include <common/system.h>
#include <sync.h>
+#include <univalue.h>
#include <util/translation.h>
#include <optional>
@@ -19,6 +20,7 @@ static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
static std::optional<bilingual_str> g_timeoffset_warning GUARDED_BY(g_warnings_mutex){};
+namespace node {
void SetMiscWarning(const bilingual_str& warning)
{
LOCK(g_warnings_mutex);
@@ -63,3 +65,18 @@ std::vector<bilingual_str> GetWarnings()
return warnings;
}
+
+UniValue GetWarningsForRpc(bool use_deprecated)
+{
+ if (use_deprecated) {
+ const auto all_warnings{GetWarnings()};
+ return all_warnings.empty() ? "" : all_warnings.back().original;
+ }
+
+ UniValue warnings{UniValue::VARR};
+ for (auto&& warning : GetWarnings()) {
+ warnings.push_back(std::move(warning.original));
+ }
+ return warnings;
+}
+} // namespace node
diff --git a/src/warnings.h b/src/node/warnings.h
index 79dc2ffabf..7766f1dbc9 100644
--- a/src/warnings.h
+++ b/src/node/warnings.h
@@ -3,20 +3,29 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_WARNINGS_H
-#define BITCOIN_WARNINGS_H
+#ifndef BITCOIN_NODE_WARNINGS_H
+#define BITCOIN_NODE_WARNINGS_H
#include <optional>
#include <string>
#include <vector>
+class UniValue;
struct bilingual_str;
+namespace node {
void SetMiscWarning(const bilingual_str& warning);
void SetfLargeWorkInvalidChainFound(bool flag);
/** Pass std::nullopt to disable the warning */
void SetMedianTimeOffsetWarning(std::optional<bilingual_str> warning);
/** Return potential problems detected by the node. */
std::vector<bilingual_str> GetWarnings();
+/**
+ * RPC helper function that wraps GetWarnings. Returns a UniValue::VSTR
+ * with the latest warning if use_deprecated is set to true, or a
+ * UniValue::VARR with all warnings otherwise.
+ */
+UniValue GetWarningsForRpc(bool use_deprecated);
+} // namespace node
-#endif // BITCOIN_WARNINGS_H
+#endif // BITCOIN_NODE_WARNINGS_H
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 46b0ae161f..cf0f67d9d3 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -29,6 +29,7 @@
#include <node/context.h>
#include <node/transaction.h>
#include <node/utxo_snapshot.h>
+#include <node/warnings.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <rpc/server_util.h>
@@ -1308,7 +1309,7 @@ RPCHelpMan getblockchaininfo()
}
}
- obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
+ obj.pushKV("warnings", node::GetWarningsForRpc(IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 6412fb35ec..22090306c6 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -20,6 +20,7 @@
#include <net.h>
#include <node/context.h>
#include <node/miner.h>
+#include <node/warnings.h>
#include <pow.h>
#include <rpc/blockchain.h>
#include <rpc/mining.h>
@@ -454,7 +455,7 @@ static RPCHelpMan getmininginfo()
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
obj.pushKV("pooledtx", (uint64_t)mempool.size());
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
- obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
+ obj.pushKV("warnings", node::GetWarningsForRpc(IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 1cc55f891a..4003e41098 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -16,6 +16,7 @@
#include <netbase.h>
#include <node/context.h>
#include <node/protocol_version.h>
+#include <node/warnings.h>
#include <policy/settings.h>
#include <protocol.h>
#include <rpc/blockchain.h>
@@ -715,7 +716,7 @@ static RPCHelpMan getnetworkinfo()
}
}
obj.pushKV("localaddresses", std::move(localAddresses));
- obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
+ obj.pushKV("warnings", node::GetWarningsForRpc(IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index bb1aef63f4..4df4466c49 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -5,17 +5,17 @@
#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
-#include <core_io.h>
#include <common/args.h>
#include <common/messages.h>
#include <common/types.h>
#include <consensus/amount.h>
-#include <script/interpreter.h>
+#include <core_io.h>
#include <key_io.h>
#include <node/types.h>
#include <outputtype.h>
#include <rpc/util.h>
#include <script/descriptor.h>
+#include <script/interpreter.h>
#include <script/signingprovider.h>
#include <script/solver.h>
#include <tinyformat.h>
@@ -25,7 +25,6 @@
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
-#include <warnings.h>
#include <algorithm>
#include <iterator>
@@ -1382,17 +1381,3 @@ void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj)
if (warnings.empty()) return;
obj.pushKV("warnings", BilingualStringsToUniValue(warnings));
}
-
-UniValue GetNodeWarnings(bool use_deprecated)
-{
- if (use_deprecated) {
- const auto all_warnings{GetWarnings()};
- return all_warnings.empty() ? "" : all_warnings.back().original;
- }
-
- UniValue warnings{UniValue::VARR};
- for (auto&& warning : GetWarnings()) {
- warnings.push_back(std::move(warning.original));
- }
- return warnings;
-}
diff --git a/src/rpc/util.h b/src/rpc/util.h
index ca6ca6007b..23024376e0 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -503,6 +503,4 @@ private:
void PushWarnings(const UniValue& warnings, UniValue& obj);
void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj);
-UniValue GetNodeWarnings(bool use_deprecated);
-
#endif // BITCOIN_RPC_UTIL_H
diff --git a/src/validation.cpp b/src/validation.cpp
index 9f8cb5f994..c14c8f872a 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -31,6 +31,7 @@
#include <logging/timer.h>
#include <node/blockstorage.h>
#include <node/utxo_snapshot.h>
+#include <node/warnings.h>
#include <policy/policy.h>
#include <policy/rbf.h>
#include <policy/settings.h>
@@ -62,7 +63,6 @@
#include <util/trace.h>
#include <util/translation.h>
#include <validationinterface.h>
-#include <warnings.h>
#include <algorithm>
#include <cassert>
@@ -1922,9 +1922,9 @@ void Chainstate::CheckForkWarningConditions()
if (m_chainman.m_best_invalid && m_chainman.m_best_invalid->nChainWork > m_chain.Tip()->nChainWork + (GetBlockProof(*m_chain.Tip()) * 6)) {
LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
- SetfLargeWorkInvalidChainFound(true);
+ node::SetfLargeWorkInvalidChainFound(true);
} else {
- SetfLargeWorkInvalidChainFound(false);
+ node::SetfLargeWorkInvalidChainFound(false);
}
}