Skip to main content

borrow_network

Function borrow_network 

Source
pub fn borrow_network(
    library: &Library,
    stop: &AtomicBool,
    rng: impl CryptoRng + Send + 'static,
) -> Result<Borrowed, NodeError>
Expand description

Borrows the network of a library’s replica, to pair: locks sync.lent, which tells the holder of the sync role to stop its endpoint, and waits until it records that it runs none, or stop is set; or, if no program holds the role, takes it, so that none starts an endpoint meanwhile. The endpoint starts again once the borrowed network goes.

§Errors

Returns NodeError::NetworkBusy if another program borrows it already, or the holder keeps its endpoint; NodeError::PairingExpired once stop is set, as pairing does; and an error if the files cannot be read or written.