Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 3: [PATCH 03/30] policy: restore conservative relay and network controls

src/net_permissions.cpp

Before: src/net_permissions.cpp · After: src/net_permissions.cpp

File metadata
index 8f0042c141f6cefba004e1285b787f33c6ca4983..458f82ac4c3a0d930f49cfdb552dada9e2a7b110 100644

Download original patch · Release notes

Diff rows 1–36 of 36. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/net_permissions.cpp CHANGED
@@ -12,12 +12,14 @@ using common::ResolveErrMsg;
12
 
13
  const std::vector<std::string> NET_PERMISSIONS_DOC{
14
  "bloomfilter (allow requesting BIP37 filtered blocks and transactions)",
 
15
  "noban (do not ban for misbehavior; implies download)",
16
  "forcerelay (relay transactions that are already in the mempool; implies relay)",
17
  "relay (relay even in -blocksonly mode, and unlimited transaction announcements)",
18
  "mempool (allow requesting BIP35 mempool contents)",
19
  "download (allow getheaders during IBD, no disconnect after maxuploadtarget limit)",
20
- "addr (responses to GETADDR avoid hitting the cache and contain random records with the most up-to-date info)"
 
21
  };
22
 
23
  namespace {
@@ -48,6 +50,7 @@ static bool TryParsePermissionFlags(const std::string& str, NetPermissionFlags&
48
  if (commaSeparator != std::string::npos) readen++; // We read ","
49
 
50
  if (permission == "bloomfilter" || permission == "bloom") NetPermissions::AddFlag(flags, NetPermissionFlags::BloomFilter);
 
51
  else if (permission == "noban") NetPermissions::AddFlag(flags, NetPermissionFlags::NoBan);
52
  else if (permission == "forcerelay") NetPermissions::AddFlag(flags, NetPermissionFlags::ForceRelay);
53
  else if (permission == "mempool") NetPermissions::AddFlag(flags, NetPermissionFlags::Mempool);
@@ -55,6 +58,7 @@ static bool TryParsePermissionFlags(const std::string& str, NetPermissionFlags&
55
  else if (permission == "all") NetPermissions::AddFlag(flags, NetPermissionFlags::All);
56
  else if (permission == "relay") NetPermissions::AddFlag(flags, NetPermissionFlags::Relay);
57
  else if (permission == "addr") NetPermissions::AddFlag(flags, NetPermissionFlags::Addr);
 
58
  else if (permission == "in") connection_direction |= ConnectionDirection::In;
59
  else if (permission == "out") {
60
  if (output_connection_direction == nullptr) {
@@ -92,6 +96,7 @@ static bool TryParsePermissionFlags(const std::string& str, NetPermissionFlags&
92
  std::vector<std::string> NetPermissions::ToStrings(NetPermissionFlags flags)
93
  {
94
  std::vector<std::string> strings;
 
95
  if (NetPermissions::HasFlag(flags, NetPermissionFlags::BloomFilter)) strings.emplace_back("bloomfilter");
96
  if (NetPermissions::HasFlag(flags, NetPermissionFlags::NoBan)) strings.emplace_back("noban");
97
  if (NetPermissions::HasFlag(flags, NetPermissionFlags::ForceRelay)) strings.emplace_back("forcerelay");
 
12
 
13
  const std::vector<std::string> NET_PERMISSIONS_DOC{
14
  "bloomfilter (allow requesting BIP37 filtered blocks and transactions)",
15
+ "blockfilters (serve compact block filters to peers per BIP157)",
16
  "noban (do not ban for misbehavior; implies download)",
17
  "forcerelay (relay transactions that are already in the mempool; implies relay)",
18
  "relay (relay even in -blocksonly mode, and unlimited transaction announcements)",
19
  "mempool (allow requesting BIP35 mempool contents)",
20
  "download (allow getheaders during IBD, no disconnect after maxuploadtarget limit)",
21
+ "addr (responses to GETADDR avoid hitting the cache and contain random records with the most up-to-date info)",
22
+ "forceinbound (when connections are full, attempt to evict a random unprotected inbound peer to open a slot; implies noban)"
23
  };
24
 
25
  namespace {
 
50
  if (commaSeparator != std::string::npos) readen++; // We read ","
51
 
52
  if (permission == "bloomfilter" || permission == "bloom") NetPermissions::AddFlag(flags, NetPermissionFlags::BloomFilter);
53
+ else if (permission == "blockfilters" || permission == "compactfilters" || permission == "cfilters") NetPermissions::AddFlag(flags, NetPermissionFlags::BlockFilters_Explicit);
54
  else if (permission == "noban") NetPermissions::AddFlag(flags, NetPermissionFlags::NoBan);
55
  else if (permission == "forcerelay") NetPermissions::AddFlag(flags, NetPermissionFlags::ForceRelay);
56
  else if (permission == "mempool") NetPermissions::AddFlag(flags, NetPermissionFlags::Mempool);
 
58
  else if (permission == "all") NetPermissions::AddFlag(flags, NetPermissionFlags::All);
59
  else if (permission == "relay") NetPermissions::AddFlag(flags, NetPermissionFlags::Relay);
60
  else if (permission == "addr") NetPermissions::AddFlag(flags, NetPermissionFlags::Addr);
61
+ else if (permission == "forceinbound") NetPermissions::AddFlag(flags, NetPermissionFlags::ForceInbound);
62
  else if (permission == "in") connection_direction |= ConnectionDirection::In;
63
  else if (permission == "out") {
64
  if (output_connection_direction == nullptr) {
 
96
  std::vector<std::string> NetPermissions::ToStrings(NetPermissionFlags flags)
97
  {
98
  std::vector<std::string> strings;
99
+ if (NetPermissions::HasFlag(flags, NetPermissionFlags::BlockFilters)) strings.emplace_back("blockfilters");
100
  if (NetPermissions::HasFlag(flags, NetPermissionFlags::BloomFilter)) strings.emplace_back("bloomfilter");
101
  if (NetPermissions::HasFlag(flags, NetPermissionFlags::NoBan)) strings.emplace_back("noban");
102
  if (NetPermissions::HasFlag(flags, NetPermissionFlags::ForceRelay)) strings.emplace_back("forcerelay");