Skip to content

Commit 69ef798

Browse files
TheBlueMattrandom-zebra
authored andcommitted
Move net-processing logic definitions together in main.h
1 parent cc51897 commit 69ef798

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

src/main.h

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class CValidationState;
6161

6262
struct PrecomputedTransactionData;
6363
struct CBlockTemplate;
64-
struct CNodeStateStats;
6564

6665
/** Default for -limitancestorcount, max number of in-mempool ancestors */
6766
static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25;
@@ -181,11 +180,6 @@ extern CBlockIndex* pindexBestHeader;
181180
/** Minimum disk space required - used in CheckDiskSpace() */
182181
static const uint64_t nMinDiskSpace = 52428800;
183182

184-
/** Register with a network node to receive its signals */
185-
void RegisterNodeSignals(CNodeSignals& nodeSignals);
186-
/** Unregister a network node */
187-
void UnregisterNodeSignals(CNodeSignals& nodeSignals);
188-
189183
/**
190184
* Process an incoming block. This only returns after the best known valid
191185
* block is made active. Note that it does not, however, guarantee that the
@@ -216,17 +210,6 @@ bool LoadBlockIndex(std::string& strError);
216210
void UnloadBlockIndex();
217211
/** See whether the protocol update is enforced for connected nodes */
218212
int ActiveProtocol();
219-
/** Process protocol messages received from a given node */
220-
bool ProcessMessages(CNode* pfrom, CConnman& connman, std::atomic<bool>& interrupt);
221-
/**
222-
* Send queued protocol messages to be sent to a give node.
223-
*
224-
* @param[in] pto The node which we are sending messages to.
225-
* @param[in] connman The connection manager for that node.
226-
* @param[in] interrupt Interrupt condition for processing threads
227-
* @return True if there is more work to be done
228-
*/
229-
bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interrupt);
230213
/** Run an instance of the script checking thread */
231214
void ThreadScriptCheck();
232215

@@ -250,10 +233,6 @@ CAmount GetBlockValue(int nHeight);
250233

251234
/** Create a new block index entry for a given block hash */
252235
CBlockIndex* InsertBlockIndex(uint256 hash);
253-
/** Get statistics from node state */
254-
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats);
255-
/** Increase a node's misbehavior score. */
256-
void Misbehaving(NodeId nodeid, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
257236
/** Flush all state, indexes and buffers to disk. */
258237
void FlushStateToDisk();
259238

@@ -266,13 +245,6 @@ int GetIXConfirmations(uint256 nTXHash);
266245
/** Convert CValidationState to a human-readable message for logging */
267246
std::string FormatStateMessage(const CValidationState &state);
268247

269-
struct CNodeStateStats {
270-
int nMisbehavior;
271-
int nSyncHeight;
272-
int nCommonHeight;
273-
std::vector<int> vHeightInFlight;
274-
};
275-
276248
CAmount GetMinRelayFee(const CTransaction& tx, const CTxMemPool& pool, unsigned int nBytes, bool fAllowFree);
277249

278250
/**
@@ -452,4 +424,37 @@ static const unsigned int REJECT_ALREADY_KNOWN = 0x101;
452424
/** Transaction conflicts with a transaction already known */
453425
static const unsigned int REJECT_CONFLICT = 0x102;
454426

427+
428+
// The following things handle network-processing logic
429+
// (and should be moved to a separate file)
430+
431+
/** Register with a network node to receive its signals */
432+
void RegisterNodeSignals(CNodeSignals& nodeSignals);
433+
/** Unregister a network node */
434+
void UnregisterNodeSignals(CNodeSignals& nodeSignals);
435+
436+
struct CNodeStateStats {
437+
int nMisbehavior;
438+
int nSyncHeight;
439+
int nCommonHeight;
440+
std::vector<int> vHeightInFlight;
441+
};
442+
443+
/** Get statistics from node state */
444+
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats);
445+
/** Increase a node's misbehavior score. */
446+
void Misbehaving(NodeId nodeid, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
447+
448+
/** Process protocol messages received from a given node */
449+
bool ProcessMessages(CNode* pfrom, CConnman& connman, std::atomic<bool>& interrupt);
450+
/**
451+
* Send queued protocol messages to be sent to a give node.
452+
*
453+
* @param[in] pto The node which we are sending messages to.
454+
* @param[in] connman The connection manager for that node.
455+
* @param[in] interrupt Interrupt condition for processing threads
456+
* @return True if there is more work to be done
457+
*/
458+
bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interrupt);
459+
455460
#endif // BITCOIN_MAIN_H

0 commit comments

Comments
 (0)