/Users/eugenesiegel/btc/bitcoin/src/node/warnings.cpp
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | // Copyright (c) 2009-2010 Satoshi Nakamoto | 
| 2 |  | // Copyright (c) 2009-2022 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 |  | #include <bitcoin-build-config.h> // IWYU pragma: keep | 
| 7 |  |  | 
| 8 |  | #include <node/warnings.h> | 
| 9 |  |  | 
| 10 |  | #include <common/system.h> | 
| 11 |  | #include <node/interface_ui.h> | 
| 12 |  | #include <sync.h> | 
| 13 |  | #include <univalue.h> | 
| 14 |  | #include <util/translation.h> | 
| 15 |  |  | 
| 16 |  | #include <utility> | 
| 17 |  | #include <vector> | 
| 18 |  |  | 
| 19 |  | namespace node { | 
| 20 |  | Warnings::Warnings() | 
| 21 | 102k | { | 
| 22 |  |     // Pre-release build warning | 
| 23 | 102k |     if (!CLIENT_VERSION_IS_RELEASE) {| Line | Count | Source |  | 12 | 102k | #define CLIENT_VERSION_IS_RELEASE false | 
 | 
| 24 | 102k |         m_warnings.insert( | 
| 25 | 102k |             {Warning::PRE_RELEASE_TEST_BUILD, | 
| 26 | 102k |              _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications")}); | 
| 27 | 102k |     } | 
| 28 | 102k | } | 
| 29 |  | bool Warnings::Set(warning_type id, bilingual_str message) | 
| 30 | 0 | { | 
| 31 | 0 |     const auto& [_, inserted]{WITH_LOCK(m_mutex, return m_warnings.insert({id, std::move(message)}))};| Line | Count | Source |  | 290 | 0 | #define WITH_LOCK(cs, code) (MaybeCheckNotHeld(cs), [&]() -> decltype(auto) { LOCK(cs); code; }()) | 
 | 
| 32 | 0 |     if (inserted) uiInterface.NotifyAlertChanged(); | 
| 33 | 0 |     return inserted; | 
| 34 | 0 | } | 
| 35 |  |  | 
| 36 |  | bool Warnings::Unset(warning_type id) | 
| 37 | 38.7k | { | 
| 38 | 38.7k |     auto success{WITH_LOCK(m_mutex, return m_warnings.erase(id))};| Line | Count | Source |  | 290 | 38.7k | #define WITH_LOCK(cs, code) (MaybeCheckNotHeld(cs), [&]() -> decltype(auto) { LOCK(cs); code; }()) | 
 | 
| 39 | 38.7k |     if (success) uiInterface.NotifyAlertChanged()0; | 
| 40 | 38.7k |     return success; | 
| 41 | 38.7k | } | 
| 42 |  |  | 
| 43 |  | std::vector<bilingual_str> Warnings::GetMessages() const | 
| 44 | 0 | { | 
| 45 | 0 |     LOCK(m_mutex); | Line | Count | Source |  | 259 | 0 | #define LOCK(cs) UniqueLock UNIQUE_NAME(criticalblock)(MaybeCheckNotHeld(cs), #cs, __FILE__, __LINE__) | Line | Count | Source |  | 11 | 0 | #define UNIQUE_NAME(name) PASTE2(name, __COUNTER__) | Line | Count | Source |  | 9 | 0 | #define PASTE2(x, y) PASTE(x, y) | Line | Count | Source |  | 8 | 0 | #define PASTE(x, y) x ## y | 
 | 
 | 
 | 
 | 
| 46 | 0 |     std::vector<bilingual_str> messages; | 
| 47 | 0 |     messages.reserve(m_warnings.size()); | 
| 48 | 0 |     for (const auto& [id, msg] : m_warnings) { | 
| 49 | 0 |         messages.push_back(msg); | 
| 50 | 0 |     } | 
| 51 | 0 |     return messages; | 
| 52 | 0 | } | 
| 53 |  |  | 
| 54 |  | UniValue GetWarningsForRpc(const Warnings& warnings, bool use_deprecated) | 
| 55 | 0 | { | 
| 56 | 0 |     if (use_deprecated) { | 
| 57 | 0 |         const auto all_messages{warnings.GetMessages()}; | 
| 58 | 0 |         return all_messages.empty() ? "" : all_messages.back().original; | 
| 59 | 0 |     } | 
| 60 |  |  | 
| 61 | 0 |     UniValue messages{UniValue::VARR}; | 
| 62 | 0 |     for (auto&& message : warnings.GetMessages()) { | 
| 63 | 0 |         messages.push_back(std::move(message.original)); | 
| 64 | 0 |     } | 
| 65 | 0 |     return messages; | 
| 66 | 0 | } | 
| 67 |  | } // namespace node |