Bitcoin Core  0.20.99
P2P Digital Currency
net_permissions.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2020 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 #include <netaddress.h>
6 
7 #include <string>
8 #include <vector>
9 
10 #ifndef BITCOIN_NET_PERMISSIONS_H
11 #define BITCOIN_NET_PERMISSIONS_H
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 tracked
23  PF_RELAY = (1U << 3),
24  // Always relay transactions from this peer, even if already in mempool
25  // Keep parameter interaction: forcerelay implies relay
26  PF_FORCERELAY = (1U << 2) | PF_RELAY,
27  // Allow getheaders during IBD and block-download after maxuploadtarget limit
28  PF_DOWNLOAD = (1U << 6),
29  // Can't be banned/disconnected/discouraged for misbehavior
30  PF_NOBAN = (1U << 4) | PF_DOWNLOAD,
31  // Can query the mempool
32  PF_MEMPOOL = (1U << 5),
33  // Can request addrs without hitting a privacy-preserving cache
34  PF_ADDR = (1U << 7),
35 
36  // True if the user did not specifically set fine grained permissions
37  PF_ISIMPLICIT = (1U << 31),
39 };
40 
42 {
43 public:
45  static std::vector<std::string> ToStrings(NetPermissionFlags flags);
46  static inline bool HasFlag(const NetPermissionFlags& flags, NetPermissionFlags f)
47  {
48  return (flags & f) == f;
49  }
51  {
52  flags = static_cast<NetPermissionFlags>(flags | f);
53  }
55  {
56  flags = static_cast<NetPermissionFlags>(flags & ~f);
57  }
58 };
59 
61 {
62 public:
63  static bool TryParse(const std::string str, NetWhitebindPermissions& output, bilingual_str& error);
65 };
66 
68 {
69 public:
70  static bool TryParse(const std::string str, NetWhitelistPermissions& output, bilingual_str& error);
72 };
73 
74 #endif // BITCOIN_NET_PERMISSIONS_H
static void AddFlag(NetPermissionFlags &flags, NetPermissionFlags f)
Bilingual messages:
Definition: translation.h:16
static void ClearFlag(NetPermissionFlags &flags, NetPermissionFlags f)
const std::vector< std::string > NET_PERMISSIONS_DOC
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:501
static bool HasFlag(const NetPermissionFlags &flags, NetPermissionFlags f)
NetPermissionFlags
NetPermissionFlags m_flags
int flags
Definition: bitcoin-tx.cpp:506
bool error(const char *fmt, const Args &... args)
Definition: system.h:52
static std::vector< std::string > ToStrings(NetPermissionFlags flags)