Expand description
Asynchronous retrieval of missing data.
FetchingDataSource combines a local storage implementation with a remote data availability
provider to create a data sources which caches data locally, but which is capable of fetching
missing data from a remote source, either proactively or on demand.
This implementation supports three kinds of data fetching.
Β§Proactive Fetching
Proactive fetching means actively scanning the local database for missing objects and proactively retrieving them from a remote provider, even if those objects have yet to be requested by a client. Doing this increases the chance of success and decreases latency when a client does eventually ask for those objects. This is also the mechanism by which a query service joining a network late, or having been offline for some time, is able to catch up with the events on the network that it missed.
Proactive fetching is implemented by a background task which performs periodic scans of the database, identifying and retrieving missing objects. This task is generally low priority, since missing objects are rare, and it will take care not to monopolize resources that could be used to serve requests.
Β§Active Fetching
Active fetching means reaching out to a remote data availability provider to retrieve a missing resource, upon receiving a request for that resource from a client. Not every request for a missing resource triggers an active fetch. To avoid spamming peers with requests for missing data, we only actively fetch resources that are known to exist somewhere. This means we can actively fetch leaves and headers when we are requested a leaf or header by height, whose height is less than the current chain height. We can fetch a block when the corresponding header exists (corresponding based on height, hash, or payload hash) or can be actively fetched.
Β§Passive Fetching
For requests that cannot be actively fetched (for example, a block requested by hash, where we do not have a header proving that a block with that hash exists), we use passive fetching. This essentially means waiting passively until the query service receives an object that satisfies the request. This object may be received because it was actively fetched in responsive to a different request for the same object, one that permitted an active fetch. Or it may have been fetched proactively.
ModulesΒ§
- block π
Fetchableimplementation forBlockQueryDataandPayloadQueryData.- header π
- Header fetching.
- leaf π
Fetchableimplementation forLeafQueryData.- transaction π
- Transaction fetching.
- vid π
Fetchableimplementation forVidCommonQueryData.
StructsΒ§
- Aggregator
Metrics π - Builder
- Builder for
FetchingDataSourcewith configuration. - Fetcher π
- Asynchronous retrieval and storage of
Fetchableresources. - Fetching
Data Source - The most basic kind of data source.
- Heights π
- Notifiers π
- Pruner
- Scanner
Metrics π
TraitsΒ§
- Availability
Provider - A provider which can be used as a fetcher by the availability service.
- Fetch
Request π - Fetchable π
- Objects which can be fetched from a remote DA provider and cached in local storage.
- Ranged
Fetchable π - Result
Ext π - Storable π
- An object which can be stored in the database.
FunctionsΒ§
- passive π
- Turn a fallible passive fetch future into an infallible βfetchβ.
- range_
chunks π - Break a range into fixed-size chunks.
- range_
chunks_ πrev - Break a range into fixed-size chunks, starting from the end and moving towards the start.
- select_
some π - Get the result of the first future to return
Some, if either do.
Type AliasesΒ§
- Passive
Fetch π