pub struct Syncing<'a> { /* private fields */ }Expand description
The library as a sync reads and changes it.
Implementations§
Source§impl<'a> Syncing<'a>
impl<'a> Syncing<'a>
Sourcepub fn new(library: &'a mut Library, now: &'a dyn Fn() -> u64) -> Self
pub fn new(library: &'a mut Library, now: &'a dyn Fn() -> u64) -> Self
A sync of library, with the wall clock now.
Trait Implementations§
Source§impl Drop for Syncing<'_>
impl Drop for Syncing<'_>
Source§impl Holder for Syncing<'_>
impl Holder for Syncing<'_>
Source§fn verifying_key(&self) -> VerifyingKey
fn verifying_key(&self) -> VerifyingKey
The replica’s verifying key.
Source§fn sign(&self, context: &'static str, message: &[u8]) -> Signature
fn sign(&self, context: &'static str, message: &[u8]) -> Signature
Signs a message with the replica’s signing key.
Source§fn spaces_with(&self, peer: &VerifyingKey) -> Result<Vec<SpaceId>, NodeError>
fn spaces_with(&self, peer: &VerifyingKey) -> Result<Vec<SpaceId>, NodeError>
The spaces the replica holds in which
peer is a replica that it syncs with, sorted
by ID: also those in which Holder::introduced took a listing of peer’s. Read moreSource§fn introductions(
&self,
peer: &[u8; 32],
) -> Result<Vec<RecoveryListing>, NodeError>
fn introductions( &self, peer: &[u8; 32], ) -> Result<Vec<RecoveryListing>, NodeError>
The listings of the replica’s own key by a recovery code, which it sends in its hello
as the initiator, so that a peer that does not know its key yet syncs with it: for the
replica whose endpoint ID is
peer, which it connected to, one for each space or group
that lists it so and that it shares with that replica, which holds those IDs already;
at most crate::MOST_INTRODUCTIONS. None by default. Read moreSource§fn introduced(
&mut self,
peer: &VerifyingKey,
listings: &[RecoveryListing],
) -> Result<(), NodeError>
fn introduced( &mut self, peer: &VerifyingKey, listings: &[RecoveryListing], ) -> Result<(), NodeError>
Takes the listings by a recovery code that
peer sent in its hello, none if it sent
none, before Holder::spaces_with, for this sync alone: a space or group for which
the replica holds a code that counts, which signed the listing of peer’s key there,
it syncs with peer as with its replicas, which brings the change that lists peer.
Takes none by default. Read moreSource§fn prepare(&mut self, space: SpaceId) -> Result<(), NodeError>
fn prepare(&mut self, space: SpaceId) -> Result<(), NodeError>
Readies a space for its sync, before
Holder::holdings: a replica brings its own
account of what it holds up to date here. One that keeps no account has nothing to do. Read moreSource§fn holdings(&self, space: SpaceId) -> Result<Vec<Holding>, NodeError>
fn holdings(&self, space: SpaceId) -> Result<Vec<Holding>, NodeError>
Everything a space holds, for reconciling. Read more
Source§fn account(
&self,
space: SpaceId,
id: &Hash,
) -> Result<Option<Vec<u8>>, NodeError>
fn account( &self, space: SpaceId, id: &Hash, ) -> Result<Option<Vec<u8>>, NodeError>
The encoding of a page of an account that the replica keeps, by the hash of its
encoding;
None if it no longer keeps it. Read moreSource§fn receive_account(
&mut self,
space: SpaceId,
page: Vec<u8>,
) -> Result<bool, NodeError>
fn receive_account( &mut self, space: SpaceId, page: Vec<u8>, ) -> Result<bool, NodeError>
Takes a page of an account from the other replica, and returns whether it kept it:
only a page that its author signed, of a replica of the space, and later than the
one of that page that it keeps. Read more
Source§fn sends(
&self,
space: SpaceId,
peer: &VerifyingKey,
holding: &Holding,
) -> Result<bool, NodeError>
fn sends( &self, space: SpaceId, peer: &VerifyingKey, holding: &Holding, ) -> Result<bool, NodeError>
Whether to send
peer an item of a space that it lacks: every item, but to a peer that
the space no longer gives what is added, as a member’s replica that was removed, only
what it may still get. What is not sent is still reconciled, so that neither side asks
for what the other holds already. Read moreSource§fn wanted_blobs(
&mut self,
space: SpaceId,
peer: &VerifyingKey,
asked: &BTreeSet<Hash>,
most: usize,
) -> Result<Vec<Hash>, NodeError>
fn wanted_blobs( &mut self, space: SpaceId, peer: &VerifyingKey, asked: &BTreeSet<Hash>, most: usize, ) -> Result<Vec<Hash>, NodeError>
The sealed blobs of a space that the replica asks
peer for, at most most of them:
those it keeps and lacks, of which peer’s account lists a copy, or all of them if it
keeps no account of peer in the space; none of asked, which it asked peer for
before in this sync of the space. Asked once what came of the space is saved. Read moreSource§fn sends_blobs(
&self,
space: SpaceId,
peer: &VerifyingKey,
) -> Result<bool, NodeError>
fn sends_blobs( &self, space: SpaceId, peer: &VerifyingKey, ) -> Result<bool, NodeError>
Whether to send
peer the sealed blobs of a space that it asks for: every one, but
none to a peer that the space no longer gives what is added. Read moreSource§fn challenges(
&mut self,
space: SpaceId,
peer: &VerifyingKey,
) -> Result<Vec<Challenge>, NodeError>
fn challenges( &mut self, space: SpaceId, peer: &VerifyingKey, ) -> Result<Vec<Challenge>, NodeError>
The challenges to put to
peer of a space’s sealed blobs, which it is to prove that it
holds now: of the copies that this replica is about to remove, for which a copy on the
peer’s disk is to stand, at most CHALLENGES_AT_ONCE, as a sync puts no more to it
in a space. None by default. Asked as the initiator, once the blobs asked for came. Read moreSource§fn proved(
&mut self,
space: SpaceId,
peer: &VerifyingKey,
challenges: &[Challenge],
answers: &[Option<[u8; 32]>],
) -> Result<(), NodeError>
fn proved( &mut self, space: SpaceId, peer: &VerifyingKey, challenges: &[Challenge], answers: &[Option<[u8; 32]>], ) -> Result<(), NodeError>
Takes
peer’s answers to the challenges put to it, in their order: None for a
blob that it did not prove. Read moreSource§fn prove(
&mut self,
space: SpaceId,
peer: &VerifyingKey,
challenges: &[Challenge],
) -> Result<Vec<Option<[u8; 32]>>, NodeError>
fn prove( &mut self, space: SpaceId, peer: &VerifyingKey, challenges: &[Challenge], ) -> Result<Vec<Option<[u8; 32]>>, NodeError>
Answers the challenges that
peer puts to this replica, in their order: for each
sealed blob of the space that it holds and is not removing, once it has recorded that
it holds the blob for a while, the answer that Challenge::answer gives from its
bytes; None for the others. Answers none by default. Read moreSource§fn parcel(
&self,
space: SpaceId,
id: ChangeId,
) -> Result<Option<Parcel>, NodeError>
fn parcel( &self, space: SpaceId, id: ChangeId, ) -> Result<Option<Parcel>, NodeError>
An accepted change with its sealed payload and wrapped keys, as far as the replica
has them. Read more
Source§fn blob(
&self,
space: SpaceId,
sealed: &Hash,
) -> Result<Option<(u64, BlobBytes<'_>)>, NodeError>
fn blob( &self, space: SpaceId, sealed: &Hash, ) -> Result<Option<(u64, BlobBytes<'_>)>, NodeError>
A sealed blob that the replica holds, with its size in bytes. Read more
Source§fn receive_change(
&mut self,
space: SpaceId,
peer: &VerifyingKey,
parcel: Parcel,
) -> Result<bool, NodeError>
fn receive_change( &mut self, space: SpaceId, peer: &VerifyingKey, parcel: Parcel, ) -> Result<bool, NodeError>
Takes a change from the other replica,
peer, and returns whether it kept anything of
it. One that the log rejects, or has already, or that the replica takes nothing like
from that peer, is dropped, and is no error. Read moreSource§fn receive_record_key(
&mut self,
space: SpaceId,
statement: StatementId,
key: WrappedKey,
) -> Result<bool, NodeError>
fn receive_record_key( &mut self, space: SpaceId, statement: StatementId, key: WrappedKey, ) -> Result<bool, NodeError>
Takes a wrapped record key from the other replica, and returns whether it kept it. Read more
Source§fn receive_blob_key(
&mut self,
space: SpaceId,
sealed: Hash,
key: WrappedBlobKey,
) -> Result<bool, NodeError>
fn receive_blob_key( &mut self, space: SpaceId, sealed: Hash, key: WrappedBlobKey, ) -> Result<bool, NodeError>
Takes a wrapped blob key from the other replica, and returns whether it kept it. Read more
Source§fn receive_blob(
&mut self,
space: SpaceId,
sealed: Hash,
size: u64,
bytes: &mut dyn Read,
) -> Result<bool, NodeError>
fn receive_blob( &mut self, space: SpaceId, sealed: Hash, size: u64, bytes: &mut dyn Read, ) -> Result<bool, NodeError>
Takes a sealed blob of
size bytes from the other replica, and returns whether it
kept it: only if its bytes have the sealed hash, and the replica wants it, such as
one whose key it holds. It need not read all of bytes, and should read none of a
blob it does not want. Read moreSource§fn finish_space(&mut self, space: SpaceId) -> Result<(), NodeError>
fn finish_space(&mut self, space: SpaceId) -> Result<(), NodeError>
Saves what was received of a space, after its last item. Read more
Source§fn pause(&mut self) -> Result<(), NodeError>
fn pause(&mut self) -> Result<(), NodeError>
Saves what it holds unsaved of what it received, as the sync is about to wait for the
other replica, or to send it items: a replica that saves received items together
does not keep them waiting on the network. One that saves each item as it comes has
nothing to do. Read more
Auto Trait Implementations§
impl<'a> !Freeze for Syncing<'a>
impl<'a> !RefUnwindSafe for Syncing<'a>
impl<'a> !Send for Syncing<'a>
impl<'a> !Sync for Syncing<'a>
impl<'a> !UnwindSafe for Syncing<'a>
impl<'a> Forget for Syncing<'a>
impl<'a> Move for Syncing<'a>
impl<'a> Unpin for Syncing<'a>
impl<'a> UnsafeUnpin for Syncing<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more