@@ -475,19 +475,70 @@ class PeerManagerImpl final : public PeerManager
475
475
/* * Offset into vExtraTxnForCompact to insert the next tx */
476
476
size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
477
477
478
+ /* * Check whether the last unknown block a peer advertised is not yet known. */
478
479
void ProcessBlockAvailability (NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
480
+ /* * Update tracking information about which blocks a peer is assumed to have. */
479
481
void UpdateBlockAvailability (NodeId nodeid, const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
480
482
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
+ */
481
490
bool BlockRequestAllowed (const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
482
491
bool AlreadyHaveBlock (const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
483
492
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
+ */
484
508
bool PrepareBlockFilterRequest (CNode& peer,
485
509
BlockFilterType filter_type, uint32_t start_height,
486
510
const uint256& stop_hash, uint32_t max_height_diff,
487
511
const CBlockIndex*& stop_index,
488
512
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
+ */
489
522
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
+ */
490
532
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
+ */
491
542
void ProcessGetCFCheckPt (CNode& peer, CDataStream& vRecv);
492
543
};
493
544
} // namespace
@@ -741,7 +792,6 @@ static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIV
741
792
return false ;
742
793
}
743
794
744
- /* * Check whether the last unknown block a peer advertised is not yet known. */
745
795
void PeerManagerImpl::ProcessBlockAvailability (NodeId nodeid) {
746
796
CNodeState *state = State (nodeid);
747
797
assert (state != nullptr );
@@ -757,7 +807,6 @@ void PeerManagerImpl::ProcessBlockAvailability(NodeId nodeid) {
757
807
}
758
808
}
759
809
760
- /* * Update tracking information about which blocks a peer is assumed to have. */
761
810
void PeerManagerImpl::UpdateBlockAvailability (NodeId nodeid, const uint256 &hash) {
762
811
CNodeState *state = State (nodeid);
763
812
assert (state != nullptr );
@@ -1182,16 +1231,6 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
1182
1231
return false ;
1183
1232
}
1184
1233
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.
1195
1234
bool PeerManagerImpl::BlockRequestAllowed (const CBlockIndex* pindex)
1196
1235
{
1197
1236
AssertLockHeld (cs_main);
@@ -2091,20 +2130,6 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
2091
2130
m_mempool.check (m_chainman.ActiveChainstate ());
2092
2131
}
2093
2132
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
- */
2108
2133
bool PeerManagerImpl::PrepareBlockFilterRequest (CNode& peer,
2109
2134
BlockFilterType filter_type, uint32_t start_height,
2110
2135
const uint256& stop_hash, uint32_t max_height_diff,
@@ -2158,14 +2183,6 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
2158
2183
return true ;
2159
2184
}
2160
2185
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
- */
2169
2186
void PeerManagerImpl::ProcessGetCFilters (CNode& peer, CDataStream& vRecv)
2170
2187
{
2171
2188
uint8_t filter_type_ser;
@@ -2197,14 +2214,6 @@ void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
2197
2214
}
2198
2215
}
2199
2216
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
- */
2208
2217
void PeerManagerImpl::ProcessGetCFHeaders (CNode& peer, CDataStream& vRecv)
2209
2218
{
2210
2219
uint8_t filter_type_ser;
@@ -2249,14 +2258,6 @@ void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
2249
2258
m_connman.PushMessage (&peer, std::move (msg));
2250
2259
}
2251
2260
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
- */
2260
2261
void PeerManagerImpl::ProcessGetCFCheckPt (CNode& peer, CDataStream& vRecv)
2261
2262
{
2262
2263
uint8_t filter_type_ser;
0 commit comments