pub fn hold<R: CryptoRng + Send + 'static>(
closed: &Closed,
role: Role,
holding: &Holding<'_>,
rng: &(dyn Fn() -> R + Sync),
told: &mut dyn FnMut(Held),
) -> Result<(), NodeError>Expand description
Holds the sync role of a closed library’s replica, and syncs it, as the technical design’s section on the sync role
says, until holding.stop is set: runs its endpoint, on which it answers every replica
that connects, each sync on a thread of its own, with a library of its own; and connects
to the others, one at a time, as it takes the role, when one appears on the network,
a while after new changes came, made here or received, and when another program asks.
Each change sets off at most one sync with each other replica: one it synced with since
the change came is not synced with again. It runs no endpoint while another program
borrows the network. Beside the syncs, on a thread of its own, it checks a share of the
replica’s copies whenever one is due, as holding.check paces it, and after a check that
found damage syncs with every replica it finds (Library::check_copies). rng makes
randomness for each thread. told hears what it does.
§Errors
Returns an error if the library cannot be opened, the records cannot be written, or the
network cannot start; a sync that fails is in what told hears.