Type Alias InboundTxDownloads

Source
type InboundTxDownloads = Downloads<Timeout<Buffer<BoxService<Request, Response, BoxError>, Request>>, Timeout<Buffer<BoxService<Request, Response, TransactionError>, Request>>, Buffer<BoxService<Request, Response, BoxError>, Request>>;

Aliased Type§

struct InboundTxDownloads {
    network: Timeout<Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>>,
    verifier: Timeout<Buffer<BoxService<Request, Response, TransactionError>, Request>>,
    state: Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>,
    pending: FuturesUnordered<JoinHandle<Result<Result<(VerifiedUnminedTx, Vec<OutPoint>, Option<Height>, Option<Sender<Result<(), Box<dyn Error + Send + Sync>>>>), (TransactionDownloadVerifyError, UnminedTxId)>, Elapsed>>>,
    cancel_handles: HashMap<UnminedTxId, (Sender<CancelDownloadAndVerify>, Gossip)>,
}

Fields§

§network: Timeout<Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>>

A service that forwards requests to connected peers, and returns their responses.

§verifier: Timeout<Buffer<BoxService<Request, Response, TransactionError>, Request>>

A service that verifies downloaded transactions.

§state: Buffer<BoxService<Request, Response, Box<dyn Error + Send + Sync>>, Request>

A service that manages cached blockchain state.

§pending: FuturesUnordered<JoinHandle<Result<Result<(VerifiedUnminedTx, Vec<OutPoint>, Option<Height>, Option<Sender<Result<(), Box<dyn Error + Send + Sync>>>>), (TransactionDownloadVerifyError, UnminedTxId)>, Elapsed>>>

A list of pending transaction download and verify tasks.

§cancel_handles: HashMap<UnminedTxId, (Sender<CancelDownloadAndVerify>, Gossip)>

A list of channels that can be used to cancel pending transaction download and verify tasks. Each channel also has the corresponding request.

Implementations

Source§

impl<ZN, ZV, ZS> Downloads<ZN, ZV, ZS>
where ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZN::Future: Send, ZV: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZV::Future: Send, ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZS::Future: Send,

Source

pub(crate) fn project<'pin>( self: Pin<&'pin mut Self>, ) -> __DownloadsProjection<'pin, ZN, ZV, ZS>

Source

pub(crate) fn project_ref<'pin>( self: Pin<&'pin Self>, ) -> __DownloadsProjectionRef<'pin, ZN, ZV, ZS>

Source§

impl<ZN, ZV, ZS> Downloads<ZN, ZV, ZS>
where ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZN::Future: Send, ZV: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZV::Future: Send, ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZS::Future: Send,

Source

pub fn new(network: ZN, verifier: ZV, state: ZS) -> Self

Initialize a new download stream with the provided services.

network is used to download transactions. verifier is used to verify transactions. state is used to check if transactions are already in the state.

The Downloads stream is agnostic to the network policy, so retry and timeout limits should be applied to the network service passed into this constructor.

Source

pub fn download_if_needed_and_verify( &mut self, gossiped_tx: Gossip, rsp_tx: Option<Sender<Result<(), Box<dyn Error + Send + Sync + 'static>>>>, ) -> Result<(), MempoolError>

Queue a transaction for download (if needed) and verification.

Returns the action taken in response to the queue request.

Source

pub fn cancel(&mut self, mined_ids: &HashSet<Hash>)

Cancel download/verification tasks of transactions with the given transaction hash (see UnminedTxId::mined_id).

Source

pub fn cancel_all(&mut self)

Cancel all running tasks and reset the downloader state.

Source

pub fn in_flight(&self) -> usize

Get the number of currently in-flight download tasks.

Source

pub fn transaction_requests(&self) -> impl Iterator<Item = &Gossip>

Get a list of the currently pending transaction requests.

Source

async fn transaction_in_best_chain( state: &mut ZS, txid: UnminedTxId, ) -> Result<(), TransactionDownloadVerifyError>

Check if transaction is already in the best chain.

Trait Implementations

Source§

impl<ZN, ZV, ZS> Debug for Downloads<ZN, ZV, ZS>
where ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static + Debug, ZN::Future: Send, ZV: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static + Debug, ZV::Future: Send, ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static + Debug, ZS::Future: Send,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<ZN, ZV, ZS> Drop for Downloads<ZN, ZV, ZS>
where ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZN::Future: Send, ZV: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZV::Future: Send, ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZS::Future: Send,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<ZN, ZV, ZS> Stream for Downloads<ZN, ZV, ZS>
where ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZN::Future: Send, ZV: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZV::Future: Send, ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZS::Future: Send,

Source§

type Item = Result<Result<(VerifiedUnminedTx, Vec<OutPoint>, Option<Height>, Option<Sender<Result<(), Box<dyn Error + Send + Sync>>>>), (UnminedTxId, TransactionDownloadVerifyError)>, Elapsed>

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more
Source§

impl<'pin, ZN, ZV, ZS> Unpin for Downloads<ZN, ZV, ZS>
where ZN: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZN::Future: Send, ZV: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZV::Future: Send, ZS: Service<Request, Response = Response, Error = Box<dyn Error + Send + Sync + 'static>> + Send + Clone + 'static, ZS::Future: Send, PinnedFieldsOf<__Downloads<'pin, ZN, ZV, ZS>>: Unpin,