Bitcoin Core 28.99.0
P2P Digital Currency
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages Concepts
net_types.h
Go to the documentation of this file.
1// Copyright (c) 2019-2021 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
11class CSubNet;
12class UniValue;
13
15{
16public:
17 static constexpr int CURRENT_VERSION{1};
19 int64_t nCreateTime{0};
20 int64_t nBanUntil{0};
21
22 CBanEntry() = default;
23
24 explicit CBanEntry(int64_t nCreateTimeIn)
25 : nCreateTime{nCreateTimeIn} {}
26
32 explicit CBanEntry(const UniValue& json);
33
38 UniValue ToJson() const;
39};
40
41using banmap_t = std::map<CSubNet, CBanEntry>;
42
49UniValue BanMapToJson(const banmap_t& bans);
50
58void BanMapFromJson(const UniValue& bans_json, banmap_t& bans);
59
60#endif // BITCOIN_NET_TYPES_H
Definition: net_types.h:15
CBanEntry()=default
int64_t nCreateTime
Definition: net_types.h:19
UniValue ToJson() const
Generate a JSON representation of this ban entry.
Definition: net_types.cpp:21
CBanEntry(int64_t nCreateTimeIn)
Definition: net_types.h:24
int nVersion
Definition: net_types.h:18
int64_t nBanUntil
Definition: net_types.h:20
static constexpr int CURRENT_VERSION
Definition: net_types.h:17
char const * json() noexcept
Template to generate JSON data.
void BanMapFromJson(const UniValue &bans_json, banmap_t &bans)
Convert a JSON array to a banmap_t object.
Definition: net_types.cpp:58
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:41
UniValue BanMapToJson(const banmap_t &bans)
Convert a banmap_t object to a JSON array.
Definition: net_types.cpp:38