trait Fetchable<Types>:
Clone
+ Send
+ Sync
+ 'staticwhere
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§
Sourcetype Request: FetchRequest
type Request: FetchRequest
A succinct specification of the object to be fetched.
Required Methods§
Sourcefn 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 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).
Sourcefn 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 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.
Sourcefn 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,
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.