reth_network_p2p/receipts/
client.rs1use std::pin::Pin;
2
3use crate::{download::DownloadClient, error::PeerRequestResult, priority::Priority};
4use alloy_consensus::TxReceipt;
5use alloy_primitives::B256;
6use futures::Future;
7use reth_eth_wire_types::Receipts70;
8
9pub type ReceiptsFut<R = reth_ethereum_primitives::Receipt> =
11 Pin<Box<dyn Future<Output = PeerRequestResult<ReceiptsResponse<R>>> + Send + Sync>>;
12
13#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct ReceiptsResponse<R> {
21 pub receipts: Vec<Vec<R>>,
23 pub last_block_incomplete: bool,
30}
31
32impl<R> ReceiptsResponse<R> {
33 #[inline]
35 pub const fn new(receipts: Vec<Vec<R>>) -> Self {
36 Self { receipts, last_block_incomplete: false }
37 }
38}
39
40impl<R> From<Receipts70<R>> for ReceiptsResponse<R> {
41 fn from(r70: Receipts70<R>) -> Self {
42 Self { receipts: r70.receipts, last_block_incomplete: r70.last_block_incomplete }
43 }
44}
45
46#[auto_impl::auto_impl(&, Arc, Box)]
48pub trait ReceiptsClient: DownloadClient {
49 type Receipt: TxReceipt;
51
52 type Output: Future<Output = PeerRequestResult<ReceiptsResponse<Self::Receipt>>>
54 + Sync
55 + Send
56 + Unpin;
57
58 fn get_receipts(&self, hashes: Vec<B256>) -> Self::Output {
60 self.get_receipts_with_priority(hashes, Priority::Normal)
61 }
62
63 fn get_receipts_with_priority(&self, hashes: Vec<B256>, priority: Priority) -> Self::Output;
65}