Skip to content

Commit 1dd8ed7

Browse files
committed
net_processing: Move comments to declarations
Also: - Remove extraneous blank line
1 parent 07156eb commit 1dd8ed7

File tree

1 file changed

+51
-50
lines changed

1 file changed

+51
-50
lines changed

src/net_processing.cpp

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -475,19 +475,70 @@ class PeerManagerImpl final : public PeerManager
475475
/** Offset into vExtraTxnForCompact to insert the next tx */
476476
size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0;
477477

478+
/** Check whether the last unknown block a peer advertised is not yet known. */
478479
void ProcessBlockAvailability(NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
480+
/** Update tracking information about which blocks a peer is assumed to have. */
479481
void UpdateBlockAvailability(NodeId nodeid, const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
480482
bool CanDirectFetch() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
483+
484+
/**
485+
* To prevent fingerprinting attacks, only send blocks/headers outside of
486+
* the active chain if they are no more than a month older (both in time,
487+
* and in best equivalent proof of work) than the best header chain we know
488+
* about and we fully-validated them at some point.
489+
*/
481490
bool BlockRequestAllowed(const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
482491
bool AlreadyHaveBlock(const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
483492
void ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv& inv);
493+
494+
/**
495+
* Validation logic for compact filters request handling.
496+
*
497+
* May disconnect from the peer in the case of a bad request.
498+
*
499+
* @param[in] peer The peer that we received the request from
500+
* @param[in] filter_type The filter type the request is for. Must be basic filters.
501+
* @param[in] start_height The start height for the request
502+
* @param[in] stop_hash The stop_hash for the request
503+
* @param[in] max_height_diff The maximum number of items permitted to request, as specified in BIP 157
504+
* @param[out] stop_index The CBlockIndex for the stop_hash block, if the request can be serviced.
505+
* @param[out] filter_index The filter index, if the request can be serviced.
506+
* @return True if the request can be serviced.
507+
*/
484508
bool PrepareBlockFilterRequest(CNode& peer,
485509
BlockFilterType filter_type, uint32_t start_height,
486510
const uint256& stop_hash, uint32_t max_height_diff,
487511
const CBlockIndex*& stop_index,
488512
BlockFilterIndex*& filter_index);
513+
514+
/**
515+
* Handle a cfilters request.
516+
*
517+
* May disconnect from the peer in the case of a bad request.
518+
*
519+
* @param[in] peer The peer that we received the request from
520+
* @param[in] vRecv The raw message received
521+
*/
489522
void ProcessGetCFilters(CNode& peer, CDataStream& vRecv);
523+
524+
/**
525+
* Handle a cfheaders request.
526+
*
527+
* May disconnect from the peer in the case of a bad request.
528+
*
529+
* @param[in] peer The peer that we received the request from
530+
* @param[in] vRecv The raw message received
531+
*/
490532
void ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv);
533+
534+
/**
535+
* Handle a getcfcheckpt request.
536+
*
537+
* May disconnect from the peer in the case of a bad request.
538+
*
539+
* @param[in] peer The peer that we received the request from
540+
* @param[in] vRecv The raw message received
541+
*/
491542
void ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv);
492543
};
493544
} // namespace
@@ -741,7 +792,6 @@ static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIV
741792
return false;
742793
}
743794

744-
/** Check whether the last unknown block a peer advertised is not yet known. */
745795
void PeerManagerImpl::ProcessBlockAvailability(NodeId nodeid) {
746796
CNodeState *state = State(nodeid);
747797
assert(state != nullptr);
@@ -757,7 +807,6 @@ void PeerManagerImpl::ProcessBlockAvailability(NodeId nodeid) {
757807
}
758808
}
759809

760-
/** Update tracking information about which blocks a peer is assumed to have. */
761810
void PeerManagerImpl::UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
762811
CNodeState *state = State(nodeid);
763812
assert(state != nullptr);
@@ -1182,16 +1231,6 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
11821231
return false;
11831232
}
11841233

1185-
1186-
//////////////////////////////////////////////////////////////////////////////
1187-
//
1188-
// blockchain -> download logic notification
1189-
//
1190-
1191-
// To prevent fingerprinting attacks, only send blocks/headers outside of the
1192-
// active chain if they are no more than a month older (both in time, and in
1193-
// best equivalent proof of work) than the best header chain we know about and
1194-
// we fully-validated them at some point.
11951234
bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)
11961235
{
11971236
AssertLockHeld(cs_main);
@@ -2091,20 +2130,6 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
20912130
m_mempool.check(m_chainman.ActiveChainstate());
20922131
}
20932132

2094-
/**
2095-
* Validation logic for compact filters request handling.
2096-
*
2097-
* May disconnect from the peer in the case of a bad request.
2098-
*
2099-
* @param[in] peer The peer that we received the request from
2100-
* @param[in] filter_type The filter type the request is for. Must be basic filters.
2101-
* @param[in] start_height The start height for the request
2102-
* @param[in] stop_hash The stop_hash for the request
2103-
* @param[in] max_height_diff The maximum number of items permitted to request, as specified in BIP 157
2104-
* @param[out] stop_index The CBlockIndex for the stop_hash block, if the request can be serviced.
2105-
* @param[out] filter_index The filter index, if the request can be serviced.
2106-
* @return True if the request can be serviced.
2107-
*/
21082133
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
21092134
BlockFilterType filter_type, uint32_t start_height,
21102135
const uint256& stop_hash, uint32_t max_height_diff,
@@ -2158,14 +2183,6 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
21582183
return true;
21592184
}
21602185

2161-
/**
2162-
* Handle a cfilters request.
2163-
*
2164-
* May disconnect from the peer in the case of a bad request.
2165-
*
2166-
* @param[in] peer The peer that we received the request from
2167-
* @param[in] vRecv The raw message received
2168-
*/
21692186
void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
21702187
{
21712188
uint8_t filter_type_ser;
@@ -2197,14 +2214,6 @@ void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
21972214
}
21982215
}
21992216

2200-
/**
2201-
* Handle a cfheaders request.
2202-
*
2203-
* May disconnect from the peer in the case of a bad request.
2204-
*
2205-
* @param[in] peer The peer that we received the request from
2206-
* @param[in] vRecv The raw message received
2207-
*/
22082217
void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
22092218
{
22102219
uint8_t filter_type_ser;
@@ -2249,14 +2258,6 @@ void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
22492258
m_connman.PushMessage(&peer, std::move(msg));
22502259
}
22512260

2252-
/**
2253-
* Handle a getcfcheckpt request.
2254-
*
2255-
* May disconnect from the peer in the case of a bad request.
2256-
*
2257-
* @param[in] peer The peer that we received the request from
2258-
* @param[in] vRecv The raw message received
2259-
*/
22602261
void PeerManagerImpl::ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv)
22612262
{
22622263
uint8_t filter_type_ser;

0 commit comments

Comments
 (0)