Bitcoin Core  27.99.0
P2P Digital Currency
warnings.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_NODE_WARNINGS_H
7 #define BITCOIN_NODE_WARNINGS_H
8 
9 #include <sync.h>
10 #include <util/translation.h>
11 
12 #include <map>
13 #include <variant>
14 #include <vector>
15 
16 class UniValue;
17 
18 namespace kernel {
19 enum class Warning;
20 } // namespace kernel
21 
22 namespace node {
23 enum class Warning {
27 };
28 
39 class Warnings
40 {
41  typedef std::variant<kernel::Warning, node::Warning> warning_type;
42 
43  mutable Mutex m_mutex;
44  std::map<warning_type, bilingual_str> m_warnings GUARDED_BY(m_mutex);
45 
46 public:
47  Warnings();
49  Warnings(const Warnings&) = delete;
50  Warnings& operator=(const Warnings&) = delete;
78  std::vector<bilingual_str> GetMessages() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
79 };
80 
87 UniValue GetWarningsForRpc(const Warnings& warnings, bool use_deprecated);
88 } // namespace node
89 
90 #endif // BITCOIN_NODE_WARNINGS_H
Manages warning messages within a node.
Definition: warnings.h:40
std::variant< kernel::Warning, node::Warning > warning_type
Definition: warnings.h:41
Warnings(const Warnings &)=delete
A warnings instance should always be passed by reference, never copied.
bool Unset(warning_type id) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Unset a warning message.
Definition: warnings.cpp:36
std::map< warning_type, bilingual_str > m_warnings GUARDED_BY(m_mutex)
Mutex m_mutex
Definition: warnings.h:43
bool Set(warning_type id, bilingual_str message) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Set a warning message.
Definition: warnings.cpp:29
Warnings & operator=(const Warnings &)=delete
std::vector< bilingual_str > GetMessages() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Return potential problems detected by the node, sorted by the warning_type id.
Definition: warnings.cpp:43
Warning
Definition: warning.h:9
Definition: messages.h:20
UniValue GetWarningsForRpc(const Warnings &warnings, bool use_deprecated)
RPC helper function that wraps warnings.GetMessages().
Definition: warnings.cpp:54
Warning
Definition: warnings.h:23
Bilingual messages:
Definition: translation.h:18
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49