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 <string>
6 #include <vector>
7 #include <netaddress.h>
8 
9 #ifndef BITCOIN_NET_PERMISSIONS_H
10 #define BITCOIN_NET_PERMISSIONS_H
12 {
13  PF_NONE = 0,
14  // Can query bloomfilter even if -peerbloomfilters is false
15  PF_BLOOMFILTER = (1U << 1),
16  // Relay and accept transactions from this peer, even if -blocksonly is true
17  PF_RELAY = (1U << 3),
18  // Always relay transactions from this peer, even if already in mempool
19  // Keep parameter interaction: forcerelay implies relay
20  PF_FORCERELAY = (1U << 2) | PF_RELAY,
21  // Can't be banned for misbehavior
22  PF_NOBAN = (1U << 4),
23  // Can query the mempool
24  PF_MEMPOOL = (1U << 5),
25 
26  // True if the user did not specifically set fine grained permissions
27  PF_ISIMPLICIT = (1U << 31),
29 };
31 {
32 public:
34  static std::vector<std::string> ToStrings(NetPermissionFlags flags);
35  static inline bool HasFlag(const NetPermissionFlags& flags, NetPermissionFlags f)
36  {
37  return (flags & f) == f;
38  }
40  {
41  flags = static_cast<NetPermissionFlags>(flags | f);
42  }
44  {
45  flags = static_cast<NetPermissionFlags>(flags & ~f);
46  }
47 };
49 {
50 public:
51  static bool TryParse(const std::string str, NetWhitebindPermissions& output, std::string& error);
53 };
54 
56 {
57 public:
58  static bool TryParse(const std::string str, NetWhitelistPermissions& output, std::string& error);
60 };
61 
62 #endif // BITCOIN_NET_PERMISSIONS_H
static void AddFlag(NetPermissionFlags &flags, NetPermissionFlags f)
static void ClearFlag(NetPermissionFlags &flags, NetPermissionFlags f)
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:138
static bool HasFlag(const NetPermissionFlags &flags, NetPermissionFlags f)
NetPermissionFlags
NetPermissionFlags m_flags
int flags
Definition: bitcoin-tx.cpp:509
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
static std::vector< std::string > ToStrings(NetPermissionFlags flags)