@@ -482,19 +482,70 @@ class PeerManagerImpl final : public PeerManager
482
482
/* * Offset into vExtraTxnForCompact to insert the next tx */
483
483
size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
484
484
485
+ /* * Check whether the last unknown block a peer advertised is not yet known. */
485
486
void ProcessBlockAvailability (NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
487
+ /* * Update tracking information about which blocks a peer is assumed to have. */
486
488
void UpdateBlockAvailability (NodeId nodeid, const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
487
489
bool CanDirectFetch () EXCLUSIVE_LOCKS_REQUIRED(cs_main);
490
+
491
+ /* *
492
+ * To prevent fingerprinting attacks, only send blocks/headers outside of
493
+ * the active chain if they are no more than a month older (both in time,
494
+ * and in best equivalent proof of work) than the best header chain we know
495
+ * about and we fully-validated them at some point.
496
+ */
488
497
bool BlockRequestAllowed (const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
489
498
bool AlreadyHaveBlock (const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
490
499
void ProcessGetBlockData (CNode& pfrom, Peer& peer, const CInv& inv);
500
+
501
+ /* *
502
+ * Validation logic for compact filters request handling.
503
+ *
504
+ * May disconnect from the peer in the case of a bad request.
505
+ *
506
+ * @param[in] peer The peer that we received the request from
507
+ * @param[in] filter_type The filter type the request is for. Must be basic filters.
508
+ * @param[in] start_height The start height for the request
509
+ * @param[in] stop_hash The stop_hash for the request
510
+ * @param[in] max_height_diff The maximum number of items permitted to request, as specified in BIP 157
511
+ * @param[out] stop_index The CBlockIndex for the stop_hash block, if the request can be serviced.
512
+ * @param[out] filter_index The filter index, if the request can be serviced.
513
+ * @return True if the request can be serviced.
514
+ */
491
515
bool PrepareBlockFilterRequest (CNode& peer,
492
516
BlockFilterType filter_type, uint32_t start_height,
493
517
const uint256& stop_hash, uint32_t max_height_diff,
494
518
const CBlockIndex*& stop_index,
495
519
BlockFilterIndex*& filter_index);
520
+
521
+ /* *
522
+ * Handle a cfilters request.
523
+ *
524
+ * May disconnect from the peer in the case of a bad request.
525
+ *
526
+ * @param[in] peer The peer that we received the request from
527
+ * @param[in] vRecv The raw message received
528
+ */
496
529
void ProcessGetCFilters (CNode& peer, CDataStream& vRecv);
530
+
531
+ /* *
532
+ * Handle a cfheaders request.
533
+ *
534
+ * May disconnect from the peer in the case of a bad request.
535
+ *
536
+ * @param[in] peer The peer that we received the request from
537
+ * @param[in] vRecv The raw message received
538
+ */
497
539
void ProcessGetCFHeaders (CNode& peer, CDataStream& vRecv);
540
+
541
+ /* *
542
+ * Handle a getcfcheckpt request.
543
+ *
544
+ * May disconnect from the peer in the case of a bad request.
545
+ *
546
+ * @param[in] peer The peer that we received the request from
547
+ * @param[in] vRecv The raw message received
548
+ */
498
549
void ProcessGetCFCheckPt (CNode& peer, CDataStream& vRecv);
499
550
};
500
551
} // namespace
@@ -748,7 +799,6 @@ static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIV
748
799
return false ;
749
800
}
750
801
751
- /* * Check whether the last unknown block a peer advertised is not yet known. */
752
802
void PeerManagerImpl::ProcessBlockAvailability (NodeId nodeid) {
753
803
CNodeState *state = State (nodeid);
754
804
assert (state != nullptr );
@@ -764,7 +814,6 @@ void PeerManagerImpl::ProcessBlockAvailability(NodeId nodeid) {
764
814
}
765
815
}
766
816
767
- /* * Update tracking information about which blocks a peer is assumed to have. */
768
817
void PeerManagerImpl::UpdateBlockAvailability (NodeId nodeid, const uint256 &hash) {
769
818
CNodeState *state = State (nodeid);
770
819
assert (state != nullptr );
@@ -1191,16 +1240,6 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
1191
1240
return false ;
1192
1241
}
1193
1242
1194
-
1195
- // ////////////////////////////////////////////////////////////////////////////
1196
- //
1197
- // blockchain -> download logic notification
1198
- //
1199
-
1200
- // To prevent fingerprinting attacks, only send blocks/headers outside of the
1201
- // active chain if they are no more than a month older (both in time, and in
1202
- // best equivalent proof of work) than the best header chain we know about and
1203
- // we fully-validated them at some point.
1204
1243
bool PeerManagerImpl::BlockRequestAllowed (const CBlockIndex* pindex)
1205
1244
{
1206
1245
AssertLockHeld (cs_main);
@@ -2101,20 +2140,6 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
2101
2140
m_mempool.check (m_chainman.ActiveChainstate ());
2102
2141
}
2103
2142
2104
- /* *
2105
- * Validation logic for compact filters request handling.
2106
- *
2107
- * May disconnect from the peer in the case of a bad request.
2108
- *
2109
- * @param[in] peer The peer that we received the request from
2110
- * @param[in] filter_type The filter type the request is for. Must be basic filters.
2111
- * @param[in] start_height The start height for the request
2112
- * @param[in] stop_hash The stop_hash for the request
2113
- * @param[in] max_height_diff The maximum number of items permitted to request, as specified in BIP 157
2114
- * @param[out] stop_index The CBlockIndex for the stop_hash block, if the request can be serviced.
2115
- * @param[out] filter_index The filter index, if the request can be serviced.
2116
- * @return True if the request can be serviced.
2117
- */
2118
2143
bool PeerManagerImpl::PrepareBlockFilterRequest (CNode& peer,
2119
2144
BlockFilterType filter_type, uint32_t start_height,
2120
2145
const uint256& stop_hash, uint32_t max_height_diff,
@@ -2168,14 +2193,6 @@ bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& peer,
2168
2193
return true ;
2169
2194
}
2170
2195
2171
- /* *
2172
- * Handle a cfilters request.
2173
- *
2174
- * May disconnect from the peer in the case of a bad request.
2175
- *
2176
- * @param[in] peer The peer that we received the request from
2177
- * @param[in] vRecv The raw message received
2178
- */
2179
2196
void PeerManagerImpl::ProcessGetCFilters (CNode& peer, CDataStream& vRecv)
2180
2197
{
2181
2198
uint8_t filter_type_ser;
@@ -2207,14 +2224,6 @@ void PeerManagerImpl::ProcessGetCFilters(CNode& peer, CDataStream& vRecv)
2207
2224
}
2208
2225
}
2209
2226
2210
- /* *
2211
- * Handle a cfheaders request.
2212
- *
2213
- * May disconnect from the peer in the case of a bad request.
2214
- *
2215
- * @param[in] peer The peer that we received the request from
2216
- * @param[in] vRecv The raw message received
2217
- */
2218
2227
void PeerManagerImpl::ProcessGetCFHeaders (CNode& peer, CDataStream& vRecv)
2219
2228
{
2220
2229
uint8_t filter_type_ser;
@@ -2259,14 +2268,6 @@ void PeerManagerImpl::ProcessGetCFHeaders(CNode& peer, CDataStream& vRecv)
2259
2268
m_connman.PushMessage (&peer, std::move (msg));
2260
2269
}
2261
2270
2262
- /* *
2263
- * Handle a getcfcheckpt request.
2264
- *
2265
- * May disconnect from the peer in the case of a bad request.
2266
- *
2267
- * @param[in] peer The peer that we received the request from
2268
- * @param[in] vRecv The raw message received
2269
- */
2270
2271
void PeerManagerImpl::ProcessGetCFCheckPt (CNode& peer, CDataStream& vRecv)
2271
2272
{
2272
2273
uint8_t filter_type_ser;
0 commit comments