pub async fn serve<T, F>(
channel: &mut PeerChannel,
offering: &Offering,
trust: &T,
versions: &dyn DirectoryVersions,
on_ack: F,
) -> Result<ServeReport, PeeringError>Expand description
Serve offering to the channel’s verified peer until it says it is done.
Reads the peer’s opening offer first when the caller has not (PeerChannel::receive_offer)
and sets it aside, then sends the listing, then answers each request in turn:
- Every request is authorized first against the trust
trustpins now (PeerSession::authorize): a peer revoked, or gone from the directory, since the handshake is refused and the session ends — as it does whentrustcannot produce current trust (fail closed). - A ranged pull is answered only for an offered address, with at most
MAX_RANGEbytes in data frames of at mostMAX_DATA_FRAME. - An acknowledgement is taken only when it names the verified peer as the delegate and an
offered address; then
on_ackdecides it. Its refusal is reported to the peer and the session goes on. - The wait for each request is the channel’s I/O timeout plus the largest
unacknowledged offered artifact at
MIN_PERSIST_RATE: the peer verifies and persists a pulled artifact before it acknowledges it, and that takes longer than one frame’s timeout for a large artifact on slow storage.
§Errors
The PeeringError that ended the session: an authorization refusal, a malformed or
unexpected frame, a timeout, or the channel failing.