Bitcoin Core  22.99.0
P2P Digital Currency
net_types.h
Go to the documentation of this file.
1 // Copyright (c) 2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_NET_TYPES_H
6 #define BITCOIN_NET_TYPES_H
7 
8 #include <cstdint>
9 #include <map>
10 
11 class CSubNet;
12 class UniValue;
13 
14 class CBanEntry
15 {
16 public:
17  static constexpr int CURRENT_VERSION{1};
19  int64_t nCreateTime{0};
20  int64_t nBanUntil{0};
21 
22  CBanEntry() {}
23 
24  explicit CBanEntry(int64_t nCreateTimeIn)
25  : nCreateTime{nCreateTimeIn} {}
26 
32  explicit CBanEntry(const UniValue& json);
33 
38  UniValue ToJson() const;
39 };
40 
41 using banmap_t = std::map<CSubNet, CBanEntry>;
42 
49 UniValue BanMapToJson(const banmap_t& bans);
50 
58 void BanMapFromJson(const UniValue& bans_json, banmap_t& bans);
59 
60 #endif // BITCOIN_NET_TYPES_H
BanMapFromJson
void BanMapFromJson(const UniValue &bans_json, banmap_t &bans)
Convert a JSON array to a banmap_t object.
Definition: net_types.cpp:54
CBanEntry::CBanEntry
CBanEntry()
Definition: net_types.h:22
UniValue
Definition: univalue.h:17
CBanEntry::nVersion
int nVersion
Definition: net_types.h:18
CSubNet
Definition: netaddress.h:475
CBanEntry::nCreateTime
int64_t nCreateTime
Definition: net_types.h:19
BanMapToJson
UniValue BanMapToJson(const banmap_t &bans)
Convert a banmap_t object to a JSON array.
Definition: net_types.cpp:34
ankerl::nanobench::templates::json
char const * json() noexcept
Template to generate JSON data.
CBanEntry
Definition: net_types.h:14
CBanEntry::ToJson
UniValue ToJson() const
Generate a JSON representation of this ban entry.
Definition: net_types.cpp:17
CBanEntry::nBanUntil
int64_t nBanUntil
Definition: net_types.h:20
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:41
CBanEntry::CURRENT_VERSION
static constexpr int CURRENT_VERSION
Definition: net_types.h:17
CBanEntry::CBanEntry
CBanEntry(int64_t nCreateTimeIn)
Definition: net_types.h:24