Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 5: [PATCH 05/17] feat(net): preserve Roots peer controls and health view on v31

src/net.h

Before: src/net.h · After: src/net.h

File metadata
index 96a171736ed3555e3997630f242f21721b8061b8..72fa4f7c2c19dfaca9f5889ec54f26ee141997ba 100644

Download original patch · Release notes

Diff rows 1–68 of 68. 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.h CHANGED
@@ -227,6 +227,8 @@ public:
227
  TransportProtocolType m_transport_type;
228
  /** BIP324 session id string in hex, if any. */
229
  std::string m_session_id;
 
 
230
  };
231
 
232
 
@@ -672,6 +674,7 @@ struct CNodeOptions
672
  std::optional<Proxy> proxy_override = {};
673
  std::unique_ptr<i2p::sam::Session> i2p_sam_session = nullptr;
674
  bool prefer_evict = false;
 
675
  size_t recv_flood_size{DEFAULT_MAXRECEIVEBUFFER * 1000};
676
  bool use_v2transport = false;
677
  };
@@ -732,6 +735,7 @@ public:
732
  * from the wire. This cleaned string can safely be logged or displayed.
733
  */
734
  std::string cleanSubVer GUARDED_BY(m_subver_mutex){};
 
735
  const bool m_prefer_evict{false}; // This peer is preferred for eviction.
736
  bool HasPermission(NetPermissionFlags permission) const {
737
  return NetPermissions::HasFlag(m_permission_flags, permission);
@@ -896,6 +900,8 @@ public:
896
  std::atomic<std::chrono::seconds> m_last_tx_time{0s};
897
 
898
  /** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/
 
 
899
  std::atomic<std::chrono::microseconds> m_last_ping_time{0us};
900
 
901
  /** Lowest measured round-trip time. Used as an inbound peer eviction
@@ -1094,6 +1100,8 @@ public:
1094
  std::vector<NetWhitebindPermissions> vWhiteBinds;
1095
  std::vector<CService> vBinds;
1096
  std::vector<CService> onion_binds;
 
 
1097
  /// True if the user did not specify -bind= or -whitebind= and thus
1098
  /// we should bind on `0.0.0.0` (IPv4) and `::` (IPv6).
1099
  bool bind_on_any;
@@ -1138,6 +1146,9 @@ public:
1138
  m_added_node_params.push_back({added_node, use_v2transport});
1139
  }
1140
  }
 
 
 
1141
  m_onion_binds = connOptions.onion_binds;
1142
  whitelist_forcerelay = connOptions.whitelist_forcerelay;
1143
  whitelist_relay = connOptions.whitelist_relay;
@@ -1510,7 +1521,7 @@ private:
1510
  */
1511
  bool AlreadyConnectedToAddress(const CNetAddr& addr) const;
1512
 
1513
- bool AttemptToEvictConnection();
1514
 
1515
  /**
1516
  * Open a new P2P connection.
@@ -1743,6 +1754,13 @@ private:
1743
  * an address and port that are designated for incoming Tor connections.
1744
  */
1745
  std::vector<CService> m_onion_binds;
 
 
 
 
 
 
 
1746
 
1747
  /**
1748
  * flag for adding 'forcerelay' permission to whitelisted inbound
 
227
  TransportProtocolType m_transport_type;
228
  /** BIP324 session id string in hex, if any. */
229
  std::string m_session_id;
230
+ bool m_forced_inbound{false};
231
+ std::chrono::nanoseconds m_cpu_time{0};
232
  };
233
 
234
 
 
674
  std::optional<Proxy> proxy_override = {};
675
  std::unique_ptr<i2p::sam::Session> i2p_sam_session = nullptr;
676
  bool prefer_evict = false;
677
+ bool forced_inbound{false};
678
  size_t recv_flood_size{DEFAULT_MAXRECEIVEBUFFER * 1000};
679
  bool use_v2transport = false;
680
  };
 
735
  * from the wire. This cleaned string can safely be logged or displayed.
736
  */
737
  std::string cleanSubVer GUARDED_BY(m_subver_mutex){};
738
+ const bool m_forced_inbound{false};
739
  const bool m_prefer_evict{false}; // This peer is preferred for eviction.
740
  bool HasPermission(NetPermissionFlags permission) const {
741
  return NetPermissions::HasFlag(m_permission_flags, permission);
 
900
  std::atomic<std::chrono::seconds> m_last_tx_time{0s};
901
 
902
  /** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/
903
+ //! Current connection message-processing CPU time, in nanoseconds.
904
+ std::atomic<int64_t> m_cpu_time{0};
905
  std::atomic<std::chrono::microseconds> m_last_ping_time{0us};
906
 
907
  /** Lowest measured round-trip time. Used as an inbound peer eviction
 
1100
  std::vector<NetWhitebindPermissions> vWhiteBinds;
1101
  std::vector<CService> vBinds;
1102
  std::vector<CService> onion_binds;
1103
+ bool listenonion{false};
1104
+ bool disable_v1conn_clearnet{false};
1105
  /// True if the user did not specify -bind= or -whitebind= and thus
1106
  /// we should bind on `0.0.0.0` (IPv4) and `::` (IPv6).
1107
  bool bind_on_any;
 
1146
  m_added_node_params.push_back({added_node, use_v2transport});
1147
  }
1148
  }
1149
+ m_normal_binds = connOptions.vBinds;
1150
+ m_listenonion = connOptions.listenonion;
1151
+ m_disable_v1conn_clearnet = connOptions.disable_v1conn_clearnet;
1152
  m_onion_binds = connOptions.onion_binds;
1153
  whitelist_forcerelay = connOptions.whitelist_forcerelay;
1154
  whitelist_relay = connOptions.whitelist_relay;
 
1521
  */
1522
  bool AlreadyConnectedToAddress(const CNetAddr& addr) const;
1523
 
1524
+ bool AttemptToEvictConnection(bool force);
1525
 
1526
  /**
1527
  * Open a new P2P connection.
 
1754
  * an address and port that are designated for incoming Tor connections.
1755
  */
1756
  std::vector<CService> m_onion_binds;
1757
+ std::vector<CService> m_normal_binds;
1758
+ bool m_listenonion{false};
1759
+ bool m_disable_v1conn_clearnet{false};
1760
+ bool DisableV1OnClearnet(Network net) const
1761
+ {
1762
+ return m_disable_v1conn_clearnet && (net == NET_IPV4 || net == NET_IPV6);
1763
+ }
1764
 
1765
  /**
1766
  * flag for adding 'forcerelay' permission to whitelisted inbound