File tree Expand file tree Collapse file tree 14 files changed +50
-39
lines changed Expand file tree Collapse file tree 14 files changed +50
-39
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,7 @@ BITCOIN_CORE_H = \
239
239
node/types.h \
240
240
node/utxo_snapshot.h \
241
241
node/validation_cache_args.h \
242
+ node/warnings.h \
242
243
noui.h \
243
244
outputtype.h \
244
245
policy/v3_policy.h \
@@ -367,7 +368,6 @@ BITCOIN_CORE_H = \
367
368
wallet/wallettool.h \
368
369
wallet/walletutil.h \
369
370
walletinitinterface.h \
370
- warnings.h \
371
371
zmq/zmqabstractnotifier.h \
372
372
zmq/zmqnotificationinterface.h \
373
373
zmq/zmqpublishnotifier.h \
@@ -444,6 +444,7 @@ libbitcoin_node_a_SOURCES = \
444
444
node/txreconciliation.cpp \
445
445
node/utxo_snapshot.cpp \
446
446
node/validation_cache_args.cpp \
447
+ node/warnings.cpp \
447
448
noui.cpp \
448
449
policy/v3_policy.cpp \
449
450
policy/fees.cpp \
@@ -721,7 +722,6 @@ libbitcoin_common_a_SOURCES = \
721
722
script/sign.cpp \
722
723
script/signingprovider.cpp \
723
724
script/solver.cpp \
724
- warnings.cpp \
725
725
$(BITCOIN_CORE_H )
726
726
#
727
727
Original file line number Diff line number Diff line change 17
17
#include < util/thread.h>
18
18
#include < util/translation.h>
19
19
#include < validation.h> // For g_chainman
20
- #include < warnings.h>
21
20
22
21
#include < string>
23
22
#include < utility>
Original file line number Diff line number Diff line change 6
6
7
7
#include < logging.h>
8
8
#include < node/interface_ui.h>
9
+ #include < node/warnings.h>
9
10
#include < util/signalinterrupt.h>
10
11
#include < util/translation.h>
11
- #include < warnings.h>
12
12
13
13
#include < atomic>
14
14
#include < cstdlib>
Original file line number Diff line number Diff line change 32
32
#include < node/mini_miner.h>
33
33
#include < node/transaction.h>
34
34
#include < node/types.h>
35
+ #include < node/warnings.h>
35
36
#include < policy/feerate.h>
36
37
#include < policy/fees.h>
37
38
#include < policy/policy.h>
53
54
#include < util/translation.h>
54
55
#include < validation.h>
55
56
#include < validationinterface.h>
56
- #include < warnings.h>
57
57
58
58
#include < config/bitcoin-config.h> // IWYU pragma: keep
59
59
Original file line number Diff line number Diff line change 13
13
#include < logging.h>
14
14
#include < node/abort.h>
15
15
#include < node/interface_ui.h>
16
+ #include < node/warnings.h>
16
17
#include < util/check.h>
17
18
#include < util/signalinterrupt.h>
18
19
#include < util/strencodings.h>
19
20
#include < util/string.h>
20
21
#include < util/translation.h>
21
- #include < warnings.h>
22
22
23
23
#include < cstdint>
24
24
#include < string>
@@ -49,7 +49,7 @@ static void AlertNotify(const std::string& strMessage)
49
49
static void DoWarning (const bilingual_str& warning)
50
50
{
51
51
static bool fWarned = false ;
52
- SetMiscWarning (warning);
52
+ node:: SetMiscWarning (warning);
53
53
if (!fWarned ) {
54
54
AlertNotify (warning.original );
55
55
fWarned = true ;
Original file line number Diff line number Diff line change 5
5
#include < logging.h>
6
6
#include < node/interface_ui.h>
7
7
#include < node/timeoffsets.h>
8
+ #include < node/warnings.h>
8
9
#include < sync.h>
9
10
#include < tinyformat.h>
10
11
#include < util/time.h>
11
12
#include < util/translation.h>
12
- #include < warnings.h>
13
13
14
14
#include < algorithm>
15
15
#include < chrono>
@@ -49,7 +49,7 @@ bool TimeOffsets::WarnIfOutOfSync() const
49
49
// when median == std::numeric_limits<int64_t>::min(), calling std::chrono::abs is UB
50
50
auto median{std::max (Median (), std::chrono::seconds (std::numeric_limits<int64_t >::min () + 1 ))};
51
51
if (std::chrono::abs (median) <= WARN_THRESHOLD) {
52
- SetMedianTimeOffsetWarning (std::nullopt);
52
+ node:: SetMedianTimeOffsetWarning (std::nullopt);
53
53
uiInterface.NotifyAlertChanged ();
54
54
return false ;
55
55
}
@@ -63,7 +63,7 @@ bool TimeOffsets::WarnIfOutOfSync() const
63
63
" RPC methods to get more info."
64
64
), Ticks<std::chrono::minutes>(WARN_THRESHOLD))};
65
65
LogWarning (" %s\n " , msg.original );
66
- SetMedianTimeOffsetWarning (msg);
66
+ node:: SetMedianTimeOffsetWarning (msg);
67
67
uiInterface.NotifyAlertChanged ();
68
68
return true ;
69
69
}
Original file line number Diff line number Diff line change 5
5
6
6
#include < config/bitcoin-config.h> // IWYU pragma: keep
7
7
8
- #include < warnings.h>
8
+ #include < node/ warnings.h>
9
9
10
10
#include < common/system.h>
11
11
#include < sync.h>
12
+ #include < univalue.h>
12
13
#include < util/translation.h>
13
14
14
15
#include < optional>
@@ -19,6 +20,7 @@ static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
19
20
static bool fLargeWorkInvalidChainFound GUARDED_BY (g_warnings_mutex) = false;
20
21
static std::optional<bilingual_str> g_timeoffset_warning GUARDED_BY (g_warnings_mutex){};
21
22
23
+ namespace node {
22
24
void SetMiscWarning (const bilingual_str& warning)
23
25
{
24
26
LOCK (g_warnings_mutex);
@@ -63,3 +65,18 @@ std::vector<bilingual_str> GetWarnings()
63
65
64
66
return warnings;
65
67
}
68
+
69
+ UniValue GetWarningsForRpc (bool use_deprecated)
70
+ {
71
+ if (use_deprecated) {
72
+ const auto all_warnings{GetWarnings ()};
73
+ return all_warnings.empty () ? " " : all_warnings.back ().original ;
74
+ }
75
+
76
+ UniValue warnings{UniValue::VARR};
77
+ for (auto && warning : GetWarnings ()) {
78
+ warnings.push_back (std::move (warning.original ));
79
+ }
80
+ return warnings;
81
+ }
82
+ } // namespace node
Original file line number Diff line number Diff line change 3
3
// Distributed under the MIT software license, see the accompanying
4
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
6
- #ifndef BITCOIN_WARNINGS_H
7
- #define BITCOIN_WARNINGS_H
6
+ #ifndef BITCOIN_NODE_WARNINGS_H
7
+ #define BITCOIN_NODE_WARNINGS_H
8
8
9
9
#include < optional>
10
10
#include < string>
11
11
#include < vector>
12
12
13
+ class UniValue ;
13
14
struct bilingual_str ;
14
15
16
+ namespace node {
15
17
void SetMiscWarning (const bilingual_str& warning);
16
18
void SetfLargeWorkInvalidChainFound (bool flag);
17
19
/* * Pass std::nullopt to disable the warning */
18
20
void SetMedianTimeOffsetWarning (std::optional<bilingual_str> warning);
19
21
/* * Return potential problems detected by the node. */
20
22
std::vector<bilingual_str> GetWarnings ();
23
+ /* *
24
+ * RPC helper function that wraps GetWarnings. Returns a UniValue::VSTR
25
+ * with the latest warning if use_deprecated is set to true, or a
26
+ * UniValue::VARR with all warnings otherwise.
27
+ */
28
+ UniValue GetWarningsForRpc (bool use_deprecated);
29
+ } // namespace node
21
30
22
- #endif // BITCOIN_WARNINGS_H
31
+ #endif // BITCOIN_NODE_WARNINGS_H
Original file line number Diff line number Diff line change 29
29
#include < node/context.h>
30
30
#include < node/transaction.h>
31
31
#include < node/utxo_snapshot.h>
32
+ #include < node/warnings.h>
32
33
#include < primitives/transaction.h>
33
34
#include < rpc/server.h>
34
35
#include < rpc/server_util.h>
@@ -1308,7 +1309,7 @@ RPCHelpMan getblockchaininfo()
1308
1309
}
1309
1310
}
1310
1311
1311
- obj.pushKV (" warnings" , GetNodeWarnings (IsDeprecatedRPCEnabled (" warnings" )));
1312
+ obj.pushKV (" warnings" , node::GetWarningsForRpc (IsDeprecatedRPCEnabled (" warnings" )));
1312
1313
return obj;
1313
1314
},
1314
1315
};
Original file line number Diff line number Diff line change 20
20
#include < net.h>
21
21
#include < node/context.h>
22
22
#include < node/miner.h>
23
+ #include < node/warnings.h>
23
24
#include < pow.h>
24
25
#include < rpc/blockchain.h>
25
26
#include < rpc/mining.h>
@@ -454,7 +455,7 @@ static RPCHelpMan getmininginfo()
454
455
obj.pushKV (" networkhashps" , getnetworkhashps ().HandleRequest (request));
455
456
obj.pushKV (" pooledtx" , (uint64_t )mempool.size ());
456
457
obj.pushKV (" chain" , chainman.GetParams ().GetChainTypeString ());
457
- obj.pushKV (" warnings" , GetNodeWarnings (IsDeprecatedRPCEnabled (" warnings" )));
458
+ obj.pushKV (" warnings" , node::GetWarningsForRpc (IsDeprecatedRPCEnabled (" warnings" )));
458
459
return obj;
459
460
},
460
461
};
You can’t perform that action at this time.
0 commit comments