Bitcoin ABC  0.26.3
P2P Digital Currency
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 
10 #include <string>
11 #include <vector>
12 
13 struct bilingual_str;
14 
15 extern const std::vector<std::string> NET_PERMISSIONS_DOC;
16 
18  PF_NONE = 0,
19  // Can query bloomfilter even if -peerbloomfilters is false
20  PF_BLOOMFILTER = (1U << 1),
21  // Relay and accept transactions from this peer, even if -blocksonly is true
22  // This peer is also not subject to limits on how many transaction INVs are
23  // tracked
24  PF_RELAY = (1U << 3),
25  // Always relay transactions from this peer, even if already in mempool
26  // Keep parameter interaction: forcerelay implies relay
27  PF_FORCERELAY = (1U << 2) | PF_RELAY,
28  // Allow getheaders during IBD and block-download after maxuploadtarget
29  // limit
30  PF_DOWNLOAD = (1U << 6),
31  // Can't be banned/disconnected/discouraged for misbehavior
32  PF_NOBAN = (1U << 4) | PF_DOWNLOAD,
33  // Can query the mempool
34  PF_MEMPOOL = (1U << 5),
35  // Can request addrs without hitting a privacy-preserving cache, and send us
36  // unlimited amounts of addrs.
37  PF_ADDR = (1U << 7),
38  // Bypass the limit on how many proof INVs are tracked from this peer as
39  // well as the delay penalty when reaching the the in-flight requests limit
41 
42  // True if the user did not specifically set fine grained permissions
43  PF_ISIMPLICIT = (1U << 31),
46 };
47 
49 public:
51  static std::vector<std::string> ToStrings(NetPermissionFlags flags);
52  static inline bool HasFlag(const NetPermissionFlags &flags,
54  return (flags & f) == f;
55  }
56  static inline void AddFlag(NetPermissionFlags &flags,
58  flags = static_cast<NetPermissionFlags>(flags | f);
59  }
60  static inline void ClearFlag(NetPermissionFlags &flags,
62  flags = static_cast<NetPermissionFlags>(flags & ~f);
63  }
64 };
65 
67 public:
68  static bool TryParse(const std::string str, NetWhitebindPermissions &output,
71 };
72 
74 public:
75  static bool TryParse(const std::string str, NetWhitelistPermissions &output,
78 };
79 
80 #endif // BITCOIN_NET_PERMISSIONS_H
int flags
Definition: bitcoin-tx.cpp:537
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 bool HasFlag(const NetPermissionFlags &flags, NetPermissionFlags f)
static void ClearFlag(NetPermissionFlags &flags, NetPermissionFlags f)
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
static bool TryParse(const std::string str, NetWhitebindPermissions &output, bilingual_str &error)
static bool TryParse(const std::string str, NetWhitelistPermissions &output, bilingual_str &error)
NetPermissionFlags
@ PF_RELAY
@ PF_ALL
@ PF_FORCERELAY
@ PF_BYPASS_PROOF_REQUEST_LIMITS
@ PF_DOWNLOAD
@ PF_ADDR
@ PF_NONE
@ PF_MEMPOOL
@ PF_NOBAN
@ PF_BLOOMFILTER
@ PF_ISIMPLICIT
const std::vector< std::string > NET_PERMISSIONS_DOC
Bilingual messages:
Definition: translation.h:17
bool error(const char *fmt, const Args &...args)
Definition: system.h:46