Skip to main content

pair_closed

Function pair_closed 

Source
pub fn pair_closed(
    closed: &Closed,
    network: &Network,
    code: &PairingCode,
    waiting: &Waiting<'_>,
    now: &dyn Fn() -> u64,
    rng: &mut impl CryptoRng,
) -> Result<Paired, NodeError>
Expand description

Pairs a new replica as pair does, with the library closed while it waits for one, so that other programs, and the app itself, can use the library in between: it is opened once a new replica connects to pair, waiting a little for another program to close it, and closed again after a try that failed before the code matched. It stops waiting, as if the time were up, once stop is set, and gives the secrets as pair_giving_secrets does if waiting says so. The caller checks first that this replica may add devices, with Library::check_not_ai_agent, before it shows the code.

ยงErrors

Returns the errors of pair; NodeError::SecretsLocked if the secrets are to be given, and closed kept none, before the code is shown; and NodeError::Store with StoreError::InUse if another program kept the library open after a new replica connected.