Skip to main content

join

Function join 

Source
pub fn join(
    directory: &Path,
    joining: Joining<'_>,
    network: &Network,
    code: &PairingCode,
    protection: &NewProtection<'_>,
    timeout: Duration,
    now: &dyn Fn() -> u64,
    rng: &mut impl CryptoRng,
) -> Result<Joined, NodeError>
Expand description

Makes a library in a directory that holds none by pairing a new replica with the replica that shows code on the network, and syncs with it: it tries each that announces the code’s first two digits in turn, waiting up to timeout to find the first. network is the new replica’s, started with Joining::network. The keys are protected as protection says. If the first sync fails, the library is removed again, as the sponsor deletes the new replica’s records: the pairing failed.

§Errors

Returns NodeError::NoSponsor if no replica announces the code in time, NodeError::Sync with SyncError::WrongCode if the code matched with none, NodeError::PairingFailed if the first sync failed, and other errors if the network or the files fail.