Skip to content

Commit

Permalink
net, net_processing: move NetEventsInterface method docs to net.h
Browse files Browse the repository at this point in the history
Summary:
Move only, comment only.

Partial backport of [[bitcoin/bitcoin#20811 | core#20811]]:
bitcoin/bitcoin@0d246a5

Ref T1696.

Depends on D10881.

Test Plan: Read the comments

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10882
  • Loading branch information
ajtowns authored and Fabcien committed Jan 25, 2022
1 parent 13db675 commit a5142b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
27 changes: 24 additions & 3 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,34 @@ class CNode {
*/
class NetEventsInterface {
public:
/** Initialize a peer (setup state, queue any initial messages) */
virtual void InitializeNode(const Config &config, CNode *pnode) = 0;

/** Handle removal of a peer (clear state) */
virtual void FinalizeNode(const Config &config, const CNode &node,
bool &update_connection_time) = 0;

/**
* Process protocol messages received from a given node
*
* @param[in] config The applicable configuration object.
* @param[in] pnode The node which we have received messages
* from.
* @param[in] interrupt Interrupt condition for processing threads
* @return True if there is more work to be done
*/
virtual bool ProcessMessages(const Config &config, CNode *pnode,
std::atomic<bool> &interrupt) = 0;

/**
* Send queued protocol messages to a given node.
*
* @param[in] config The applicable configuration object.
* @param[in] pnode The node which we are sending messages to.
* @return True if there is more work to be done
*/
virtual bool SendMessages(const Config &config, CNode *pnode)
EXCLUSIVE_LOCKS_REQUIRED(pnode->cs_sendProcessing) = 0;
virtual void InitializeNode(const Config &config, CNode *pnode) = 0;
virtual void FinalizeNode(const Config &config, const CNode &node,
bool &update_connection_time) = 0;

protected:
/**
Expand Down
22 changes: 0 additions & 22 deletions src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,33 +149,11 @@ class PeerManager final : public CValidationInterface,
void NewPoWValidBlock(const CBlockIndex *pindex,
const std::shared_ptr<const CBlock> &pblock) override;

/**
* Initialize a peer by adding it to mapNodeState and pushing a message
* requesting its version.
*/
void InitializeNode(const Config &config, CNode *pnode) override;
/**
* Handle removal of a peer by updating various state and removing it from
* mapNodeState.
*/
void FinalizeNode(const Config &config, const CNode &node,
bool &fUpdateConnectionTime) override;
/**
* Process protocol messages received from a given node
*
* @param[in] config The applicable configuration object.
* @param[in] pfrom The node which we have received messages from.
* @param[in] interrupt Interrupt condition for processing threads
*/
bool ProcessMessages(const Config &config, CNode *pfrom,
std::atomic<bool> &interrupt) override;
/**
* Send queued protocol messages to be sent to a give node.
*
* @param[in] config The applicable configuration object.
* @param[in] pto The node which we are sending messages to.
* @return True if there is more work to be done
*/
bool SendMessages(const Config &config, CNode *pto) override
EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);

Expand Down

0 comments on commit a5142b4

Please sign in to comment.