aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2020-12-30 18:41:45 +1000
committerAnthony Towns <aj@erisian.com.au>2021-01-09 23:27:45 +1000
commitc97f70c861ac6959b8116a9bca3031edeb2b2aaa (patch)
tree70af0a75d2d5bdde1030051f64e9401eddb15301
parente0f2e6d2df7117a8dbf17c63c5149fc53a6fe2b2 (diff)
net_processing: move Peer definition to .cpp
-rw-r--r--src/net_processing.cpp55
-rw-r--r--src/net_processing.h55
2 files changed, 55 insertions, 55 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 94e092592b..3faff5dd49 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -169,6 +169,61 @@ void EraseOrphansFor(NodeId peer);
// Internal stuff
namespace {
+/**
+ * Data structure for an individual peer. This struct is not protected by
+ * cs_main since it does not contain validation-critical data.
+ *
+ * Memory is owned by shared pointers and this object is destructed when
+ * the refcount drops to zero.
+ *
+ * Mutexes inside this struct must not be held when locking m_peer_mutex.
+ *
+ * TODO: move most members from CNodeState to this structure.
+ * TODO: move remaining application-layer data members from CNode to this structure.
+ */
+struct Peer {
+ /** Same id as the CNode object for this peer */
+ const NodeId m_id{0};
+
+ /** Protects misbehavior data members */
+ Mutex m_misbehavior_mutex;
+ /** Accumulated misbehavior score for this peer */
+ int m_misbehavior_score GUARDED_BY(m_misbehavior_mutex){0};
+ /** Whether this peer should be disconnected and marked as discouraged (unless it has the noban permission). */
+ bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
+
+ /** Protects block inventory data members */
+ Mutex m_block_inv_mutex;
+ /** List of blocks that we'll announce via an `inv` message.
+ * There is no final sorting before sending, as they are always sent
+ * immediately and in the order requested. */
+ std::vector<uint256> m_blocks_for_inv_relay GUARDED_BY(m_block_inv_mutex);
+ /** Unfiltered list of blocks that we'd like to announce via a `headers`
+ * message. If we can't announce via a `headers` message, we'll fall back to
+ * announcing via `inv`. */
+ std::vector<uint256> m_blocks_for_headers_relay GUARDED_BY(m_block_inv_mutex);
+ /** The final block hash that we sent in an `inv` message to this peer.
+ * When the peer requests this block, we send an `inv` message to trigger
+ * the peer to request the next sequence of block hashes.
+ * Most peers use headers-first syncing, which doesn't use this mechanism */
+ uint256 m_continuation_block GUARDED_BY(m_block_inv_mutex) {};
+
+ /** This peer's reported block height when we connected */
+ std::atomic<int> m_starting_height{-1};
+
+ /** Set of txids to reconsider once their parent transactions have been accepted **/
+ std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
+
+ /** Protects m_getdata_requests **/
+ Mutex m_getdata_requests_mutex;
+ /** Work queue of items requested by this peer **/
+ std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex);
+
+ explicit Peer(NodeId id) : m_id(id) {}
+};
+
+using PeerRef = std::shared_ptr<Peer>;
+
class PeerManagerImpl final : public PeerManager
{
public:
diff --git a/src/net_processing.h b/src/net_processing.h
index e86997190a..eaa3b142a8 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -33,61 +33,6 @@ struct CNodeStateStats {
std::vector<int> vHeightInFlight;
};
-/**
- * Data structure for an individual peer. This struct is not protected by
- * cs_main since it does not contain validation-critical data.
- *
- * Memory is owned by shared pointers and this object is destructed when
- * the refcount drops to zero.
- *
- * Mutexes inside this struct must not be held when locking m_peer_mutex.
- *
- * TODO: move most members from CNodeState to this structure.
- * TODO: move remaining application-layer data members from CNode to this structure.
- */
-struct Peer {
- /** Same id as the CNode object for this peer */
- const NodeId m_id{0};
-
- /** Protects misbehavior data members */
- Mutex m_misbehavior_mutex;
- /** Accumulated misbehavior score for this peer */
- int m_misbehavior_score GUARDED_BY(m_misbehavior_mutex){0};
- /** Whether this peer should be disconnected and marked as discouraged (unless it has the noban permission). */
- bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
-
- /** Protects block inventory data members */
- Mutex m_block_inv_mutex;
- /** List of blocks that we'll announce via an `inv` message.
- * There is no final sorting before sending, as they are always sent
- * immediately and in the order requested. */
- std::vector<uint256> m_blocks_for_inv_relay GUARDED_BY(m_block_inv_mutex);
- /** Unfiltered list of blocks that we'd like to announce via a `headers`
- * message. If we can't announce via a `headers` message, we'll fall back to
- * announcing via `inv`. */
- std::vector<uint256> m_blocks_for_headers_relay GUARDED_BY(m_block_inv_mutex);
- /** The final block hash that we sent in an `inv` message to this peer.
- * When the peer requests this block, we send an `inv` message to trigger
- * the peer to request the next sequence of block hashes.
- * Most peers use headers-first syncing, which doesn't use this mechanism */
- uint256 m_continuation_block GUARDED_BY(m_block_inv_mutex) {};
-
- /** This peer's reported block height when we connected */
- std::atomic<int> m_starting_height{-1};
-
- /** Set of txids to reconsider once their parent transactions have been accepted **/
- std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
-
- /** Protects m_getdata_requests **/
- Mutex m_getdata_requests_mutex;
- /** Work queue of items requested by this peer **/
- std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex);
-
- explicit Peer(NodeId id) : m_id(id) {}
-};
-
-using PeerRef = std::shared_ptr<Peer>;
-
class PeerManager : public CValidationInterface, public NetEventsInterface
{
public: