Skip to content
Bitcoin Roots

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

src/net_processing.h

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

File metadata
index 0d2dc59c5ae92e63fb635683a1bb7c1483fad60d..4ce9f409c94ae3be4afc80e476307d6901f15f84 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_processing.h CHANGED
@@ -7,6 +7,7 @@
7
  #define BITCOIN_NET_PROCESSING_H
8
 
9
  #include <net.h>
 
10
  #include <txorphanage.h>
11
  #include <validationinterface.h>
12
 
@@ -23,11 +24,15 @@ class Warnings;
23
 
24
  /** Whether transaction reconciliation protocol should be enabled by default. */
25
  static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false};
 
 
26
  /** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
27
  static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS{100};
 
 
28
  /** Default number of non-mempool transactions to keep around for block reconstruction. Includes
29
  orphan, replaced, and rejected transactions. */
30
- static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100};
31
  static const bool DEFAULT_PEERBLOOMFILTERS = false;
32
  static const bool DEFAULT_PEERBLOCKFILTERS = false;
33
  /** Maximum number of outstanding CMPCTBLOCK requests for the same block. */
@@ -50,6 +55,8 @@ struct CNodeStateStats {
50
  ServiceFlags their_services;
51
  int64_t presync_height{-1};
52
  std::chrono::seconds time_offset{0};
 
 
53
  };
54
 
55
  struct PeerManagerInfo {
@@ -70,6 +77,7 @@ public:
70
  //! Number of non-mempool transactions to keep around for block reconstruction. Includes
71
  //! orphan, replaced, and rejected transactions.
72
  uint32_t max_extra_txs{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN};
 
73
  //! Whether all P2P messages are captured to disk
74
  bool capture_messages{false};
75
  //! Whether or not the internal RNG behaves deterministically (this is
@@ -86,20 +94,20 @@ public:
86
  virtual ~PeerManager() = default;
87
 
88
  /**
89
- * Attempt to manually fetch block from a given peer. We must already have the header.
90
  *
91
  * @param[in] peer_id The peer id
92
  * @param[in] block_index The blockindex
93
  * @returns std::nullopt if a request was successfully made, otherwise an error message
94
  */
95
- virtual std::optional<std::string> FetchBlock(NodeId peer_id, const CBlockIndex& block_index) = 0;
 
96
 
97
  /** Begin running background tasks, should only be called once */
98
  virtual void StartScheduledTasks(CScheduler& scheduler) = 0;
99
 
100
  /** Get statistics from node state */
101
  virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0;
102
-
103
  virtual std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() = 0;
104
 
105
  /** Get peer manager info. */
@@ -152,6 +160,7 @@ public:
152
  * we do not have a confirmed set of service flags.
153
  */
154
  virtual ServiceFlags GetDesirableServiceFlags(ServiceFlags services) const = 0;
 
155
  };
156
 
157
  #endif // BITCOIN_NET_PROCESSING_H
 
7
  #define BITCOIN_NET_PROCESSING_H
8
 
9
  #include <net.h>
10
+ #include <threadsafety.h>
11
  #include <txorphanage.h>
12
  #include <validationinterface.h>
13
 
 
24
 
25
  /** Whether transaction reconciliation protocol should be enabled by default. */
26
  static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false};
27
+ /** Whether to announce a fee filter to compatible transaction-relay peers. */
28
+ static constexpr bool DEFAULT_FEEFILTER{true};
29
  /** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
30
  static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS{100};
31
+ static constexpr size_t BLOCK_RECONSTRUCTION_EXTRA_TXN_PER_TXN_SIZE_LIMIT{100000};
32
+ static const size_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN_SIZE{10000000};
33
  /** Default number of non-mempool transactions to keep around for block reconstruction. Includes
34
  orphan, replaced, and rejected transactions. */
35
+ static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{32768};
36
  static const bool DEFAULT_PEERBLOOMFILTERS = false;
37
  static const bool DEFAULT_PEERBLOCKFILTERS = false;
38
  /** Maximum number of outstanding CMPCTBLOCK requests for the same block. */
 
55
  ServiceFlags their_services;
56
  int64_t presync_height{-1};
57
  std::chrono::seconds time_offset{0};
58
+ NodeSeconds m_last_block_announcement;
59
+ int m_misbehavior_score{0};
60
  };
61
 
62
  struct PeerManagerInfo {
 
77
  //! Number of non-mempool transactions to keep around for block reconstruction. Includes
78
  //! orphan, replaced, and rejected transactions.
79
  uint32_t max_extra_txs{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN};
80
+ size_t max_extra_txs_size{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN_SIZE};
81
  //! Whether all P2P messages are captured to disk
82
  bool capture_messages{false};
83
  //! Whether or not the internal RNG behaves deterministically (this is
 
94
  virtual ~PeerManager() = default;
95
 
96
  /**
97
+ * Attempt to manually fetch block from a given peer.
98
  *
99
  * @param[in] peer_id The peer id
100
  * @param[in] block_index The blockindex
101
  * @returns std::nullopt if a request was successfully made, otherwise an error message
102
  */
103
+ std::optional<std::string> FetchBlock(NodeId peer_id, const CBlockIndex& block_index);
104
+ virtual std::optional<std::string> FetchBlock(NodeId peer_id, const uint256& hash, const CBlockIndex* block_index) = 0;
105
 
106
  /** Begin running background tasks, should only be called once */
107
  virtual void StartScheduledTasks(CScheduler& scheduler) = 0;
108
 
109
  /** Get statistics from node state */
110
  virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0;
 
111
  virtual std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() = 0;
112
 
113
  /** Get peer manager info. */
 
160
  * we do not have a confirmed set of service flags.
161
  */
162
  virtual ServiceFlags GetDesirableServiceFlags(ServiceFlags services) const = 0;
163
+
164
  };
165
 
166
  #endif // BITCOIN_NET_PROCESSING_H