Function trigger_fetch_for_parent

Source
pub(super) fn trigger_fetch_for_parent<Types, S, P>(
    fetcher: &Arc<Fetcher<Types, S, P>>,
    leaf: &LeafQueryData<Types>,
)
where Types: NodeType, Header<Types>: QueryableHeader<Types>, Payload<Types>: QueryablePayload<Types>, S: VersionedDataSource + 'static, for<'a> S::Transaction<'a>: UpdateAvailabilityStorage<Types>, for<'a> S::ReadOnly<'a>: AvailabilityStorage<Types> + NodeStorage<Types> + PrunedHeightStorage, P: AvailabilityProvider<Types>,
Expand description

Trigger a fetch of the parent of the given leaf, if it is missing.

Leaves have a unique constraint among fetchable objects: we cannot fetch a given leaf at height h unless we have its child at height h + 1. This is because the child, through its parent_commitment, tells us what the hash of the parent should be, which lets us authenticate it when fetching from an untrusted provider. Thus, requests for leaf h might block if h + 1 is not available. To ensure all these requests are eventually unblocked, and all leaves are eventually fetched, we call this function whenever we receive leaf h + 1 to check if we need to then fetch leaf h.