Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
net_permissions.h
Go to the documentation of this file.
1// Copyright (c) 2009-2018 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_PERMISSIONS_H
6#define BITCOIN_NET_PERMISSIONS_H
7
8#include <netaddress.h>
9#include <netbase.h>
10
11#include <string>
12#include <type_traits>
13#include <vector>
14
15struct bilingual_str;
16
17extern const std::vector<std::string> NET_PERMISSIONS_DOC;
18
20static const bool DEFAULT_WHITELISTRELAY = true;
22static const bool DEFAULT_WHITELISTFORCERELAY = false;
23
25 None = 0,
26 // Can query bloomfilter even if -peerbloomfilters is false
27 BloomFilter = (1U << 1),
28 // Relay and accept transactions from this peer, even if -blocksonly is true
29 // This peer is also not subject to limits on how many transaction INVs are
30 // tracked
31 Relay = (1U << 3),
32 // Always relay transactions from this peer, even if already in mempool
33 // Keep parameter interaction: forcerelay implies relay
34 ForceRelay = (1U << 2) | Relay,
35 // Allow getheaders during IBD and block-download after maxuploadtarget
36 // limit
37 Download = (1U << 6),
38 // Can't be banned/disconnected/discouraged for misbehavior
39 NoBan = (1U << 4) | Download,
40 // Can query the mempool
41 Mempool = (1U << 5),
42 // Can request addrs without hitting a privacy-preserving cache, and send us
43 // unlimited amounts of addrs.
44 Addr = (1U << 7),
45 // Bypass the limit on how many proof INVs are tracked from this peer as
46 // well as the delay penalty when reaching the the in-flight requests limit
47 BypassProofRequestLimits = (1U << 30),
48
49 // True if the user did not specifically set fine grained permissions
50 Implicit = (1U << 31),
53};
56 using t = typename std::underlying_type<NetPermissionFlags>::type;
57 return static_cast<NetPermissionFlags>(static_cast<t>(a) |
58 static_cast<t>(b));
59}
60
62public:
64 static std::vector<std::string> ToStrings(NetPermissionFlags flags);
66 using t = typename std::underlying_type<NetPermissionFlags>::type;
67 return (static_cast<t>(flags) & static_cast<t>(f)) == static_cast<t>(f);
68 }
69 static inline void AddFlag(NetPermissionFlags &flags,
71 flags = flags | f;
72 }
79 static inline void ClearFlag(NetPermissionFlags &flags,
82 using t = typename std::underlying_type<NetPermissionFlags>::type;
83 flags = static_cast<NetPermissionFlags>(static_cast<t>(flags) &
84 ~static_cast<t>(f));
85 }
86};
87
89public:
90 static bool TryParse(const std::string &str,
93};
94
96public:
97 static bool TryParse(const std::string &str,
102};
103
104#endif // BITCOIN_NET_PERMISSIONS_H
int flags
A combination of a network address (CNetAddr) and a (TCP) port.
Definition netaddress.h:545
NetPermissionFlags m_flags
static void AddFlag(NetPermissionFlags &flags, NetPermissionFlags f)
static void ClearFlag(NetPermissionFlags &flags, NetPermissionFlags f)
ClearFlag is only called with f == NetPermissionFlags::Implicit.
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
static bool HasFlag(NetPermissionFlags flags, NetPermissionFlags f)
static bool TryParse(const std::string &str, NetWhitebindPermissions &output, bilingual_str &error)
static bool TryParse(const std::string &str, NetWhitelistPermissions &output, ConnectionDirection &output_connection_direction, bilingual_str &error)
bool error(const char *fmt, const Args &...args)
Definition logging.h:263
static const bool DEFAULT_WHITELISTFORCERELAY
Default for -whitelistforcerelay.
static const bool DEFAULT_WHITELISTRELAY
Default for -whitelistrelay.
static constexpr NetPermissionFlags operator|(NetPermissionFlags a, NetPermissionFlags b)
NetPermissionFlags
const std::vector< std::string > NET_PERMISSIONS_DOC
ConnectionDirection
Definition netbase.h:32
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
Bilingual messages:
Definition translation.h:17
assert(!tx.IsCoinBase())