@@ -882,15 +882,19 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
882
882
if unsolicited > 0 {
883
883
self . metrics . unsolicited_transactions . increment ( unsolicited as u64 ) ;
884
884
}
885
- if verification_outcome == VerificationOutcome :: ReportPeer {
886
- // todo: report peer for sending hashes that weren't requested
885
+
886
+ let report_peer = if verification_outcome == VerificationOutcome :: ReportPeer {
887
887
trace ! ( target: "net::tx" ,
888
888
peer_id=format!( "{peer_id:#}" ) ,
889
889
unverified_len,
890
890
verified_payload_len=verified_payload. len( ) ,
891
891
"received `PooledTransactions` response from peer with entries that didn't verify against request, filtered out transactions"
892
892
) ;
893
- }
893
+ true
894
+ } else {
895
+ false
896
+ } ;
897
+
894
898
// peer has only sent hashes that we didn't request
895
899
if verified_payload. is_empty ( ) {
896
900
return FetchEvent :: FetchError { peer_id, error : RequestError :: BadResponse }
@@ -952,7 +956,7 @@ impl<N: NetworkPrimitives> TransactionFetcher<N> {
952
956
953
957
let transactions = valid_payload. into_data ( ) . into_values ( ) . collect ( ) ;
954
958
955
- FetchEvent :: TransactionsFetched { peer_id, transactions }
959
+ FetchEvent :: TransactionsFetched { peer_id, transactions, report_peer }
956
960
}
957
961
Ok ( Err ( req_err) ) => {
958
962
self . try_buffer_hashes_for_retry ( requested_hashes, & peer_id) ;
@@ -1039,6 +1043,9 @@ pub enum FetchEvent<T = PooledTransaction> {
1039
1043
peer_id : PeerId ,
1040
1044
/// The transactions that were fetched, if available.
1041
1045
transactions : PooledTransactions < T > ,
1046
+ /// Whether the peer should be penalized for sending unsolicited transactions or for
1047
+ /// misbehavior.
1048
+ report_peer : bool ,
1042
1049
} ,
1043
1050
/// Triggered when there is an error in fetching transactions.
1044
1051
FetchError {
0 commit comments