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,
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§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,
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,
Sourcepub fn new(network: ZN, verifier: ZV, state: ZS) -> Self
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.
Sourcepub fn download_if_needed_and_verify(
&mut self,
gossiped_tx: Gossip,
rsp_tx: Option<Sender<Result<(), Box<dyn Error + Send + Sync + 'static>>>>,
) -> Result<(), MempoolError>
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.
Sourcepub fn cancel(&mut self, mined_ids: &HashSet<Hash>)
pub fn cancel(&mut self, mined_ids: &HashSet<Hash>)
Cancel download/verification tasks of transactions with the
given transaction hash (see UnminedTxId::mined_id
).
Sourcepub fn cancel_all(&mut self)
pub fn cancel_all(&mut self)
Cancel all running tasks and reset the downloader state.
Sourcepub fn transaction_requests(&self) -> impl Iterator<Item = &Gossip>
pub fn transaction_requests(&self) -> impl Iterator<Item = &Gossip>
Get a list of the currently pending transaction requests.
Sourceasync fn transaction_in_best_chain(
state: &mut ZS,
txid: UnminedTxId,
) -> Result<(), TransactionDownloadVerifyError>
async fn transaction_in_best_chain( state: &mut ZS, txid: UnminedTxId, ) -> Result<(), TransactionDownloadVerifyError>
Check if transaction is already in the best chain.