Trait Fetchable

Source
trait Fetchable<Types>:
    Clone
    + Send
    + Sync
    + 'static
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,
{ type Request: FetchRequest; // Required methods fn satisfies(&self, req: Self::Request) -> bool; fn active_fetch<'life0, 'async_trait, S, P>( tx: &'life0 mut (impl 'async_trait + AvailabilityStorage<Types>), fetcher: Arc<Fetcher<Types, S, P>>, req: Self::Request, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where S: VersionedDataSource + 'static + 'async_trait, for<'a> S::Transaction<'a>: UpdateAvailabilityStorage<Types>, for<'a> S::ReadOnly<'a>: AvailabilityStorage<Types> + NodeStorage<Types> + PrunedHeightStorage, P: AvailabilityProvider<Types> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; fn passive_fetch<'life0, 'async_trait>( notifiers: &'life0 Notifiers<Types>, req: Self::Request, ) -> Pin<Box<dyn Future<Output = BoxFuture<'static, Option<Self>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn load<'life0, 'async_trait, S>( storage: &'life0 mut S, req: Self::Request, ) -> Pin<Box<dyn Future<Output = QueryResult<Self>> + Send + 'async_trait>> where S: AvailabilityStorage<Types> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait; }
Expand description

Objects which can be fetched from a remote DA provider and cached in local storage.

This trait lets us abstract over leaves, blocks, and other types that can be fetched. Thus, the logistics of fetching are shared between all objects, and only the low-level particulars are type-specific.

Required Associated Types§

Source

type Request: FetchRequest

A succinct specification of the object to be fetched.

Required Methods§

Source

fn satisfies(&self, req: Self::Request) -> bool

Does this object satisfy the given request?

Source

fn active_fetch<'life0, 'async_trait, S, P>( tx: &'life0 mut (impl 'async_trait + AvailabilityStorage<Types>), fetcher: Arc<Fetcher<Types, S, P>>, req: Self::Request, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where S: VersionedDataSource + 'static + 'async_trait, for<'a> S::Transaction<'a>: UpdateAvailabilityStorage<Types>, for<'a> S::ReadOnly<'a>: AvailabilityStorage<Types> + NodeStorage<Types> + PrunedHeightStorage, P: AvailabilityProvider<Types> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Spawn a task to fetch the object from a remote provider, if possible.

An active fetch will only be triggered if:

  • There is not already an active fetch in progress for the same object
  • The requested object is known to exist. For example, we will fetch a leaf by height but not by hash, since we can’t guarantee that a leaf with an arbitrary hash exists. Note that this function assumes req.might_exist() has already been checked before calling it, and so may do unnecessary work if the caller does not ensure this.

If we do trigger an active fetch for an object, any passive listeners for the object will be notified once it has been retrieved. If we do not trigger an active fetch for an object, this function does nothing. In either case, as long as the requested object does in fact exist, we will eventually receive it passively, since we will eventually receive all blocks and leaves that are ever produced. Active fetching merely helps us receive certain objects sooner.

This function fails if it might be possible to actively fetch the requested object, but we were unable to do so (e.g. due to errors in the database).

Source

fn passive_fetch<'life0, 'async_trait>( notifiers: &'life0 Notifiers<Types>, req: Self::Request, ) -> Pin<Box<dyn Future<Output = BoxFuture<'static, Option<Self>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Wait for someone else to fetch the object.

Source

fn load<'life0, 'async_trait, S>( storage: &'life0 mut S, req: Self::Request, ) -> Pin<Box<dyn Future<Output = QueryResult<Self>> + Send + 'async_trait>>
where S: AvailabilityStorage<Types> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Load an object from local storage.

This function assumes req.might_exist() has already been checked before calling it, and so may do unnecessary work if the caller does not ensure this.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Types> Fetchable<Types> for BlockQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

type Request = BlockId<Types>

Source§

impl<Types> Fetchable<Types> for HeaderQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

type Request = BlockId<Types>

Source§

impl<Types> Fetchable<Types> for LeafQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

type Request = LeafId<Types>

Source§

impl<Types> Fetchable<Types> for PayloadMetadata<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

type Request = BlockId<Types>

Source§

impl<Types> Fetchable<Types> for PayloadQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

type Request = BlockId<Types>

Source§

impl<Types> Fetchable<Types> for StateCertQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

impl<Types> Fetchable<Types> for TransactionQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

impl<Types> Fetchable<Types> for VidCommonMetadata<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,

Source§

impl<Types> Fetchable<Types> for VidCommonQueryData<Types>
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>,