pub struct Writer<S: TileStore> { /* private fields */ }Expand description
The one writer of a log. Holds .state/treeState.lock from open to drop.
Implementations§
Source§impl<S: TileStore> Writer<S>
impl<S: TileStore> Writer<S>
Sourcepub fn open(store: S, keys: KeyFn) -> Result<Self>
pub fn open(store: S, keys: KeyFn) -> Result<Self>
Opens the log on store, takes the writer lock, quarantines a torn
tail, loads the frontier and completes the sidecars and manifest of
every sealed bundle. keys derives the lookup keys of an entry from
its bytes (crate::index::no_keys for the identity hash alone); a
reader has to use the same function. Error::Locked when another
writer holds the lock; a lock left by a crashed writer has to be
removed by hand.
Sourcepub fn tree_state(&self) -> TreeState
pub fn tree_state(&self) -> TreeState
The tree state the tiles are complete to.
Sourcepub fn quarantined(&self) -> (&[String], Option<&str>)
pub fn quarantined(&self) -> (&[String], Option<&str>)
Store paths open moved aside because the tree state did not cover
them, and the .state/torn-<utc> directory they went to.
Sourcepub fn append_batch<I>(&mut self, entries: I) -> Result<Range<u64>>
pub fn append_batch<I>(&mut self, entries: I) -> Result<Range<u64>>
Appends entries in order and returns their index range. Nothing is written when any entry is over 65535 bytes. Bundles, tiles and the tree state are each written once for the whole batch.
Sourcepub fn checkpoint(&self, signer: &Signer, origin: &str) -> Result<Note>
pub fn checkpoint(&self, signer: &Signer, origin: &str) -> Result<Note>
Signs the tree state as a C2SP checkpoint under origin and writes
it at checkpoint, holding .state/publish.lock meanwhile. A
checkpoint already published for a larger size is never replaced, so
the signer never signs a checkpoint inconsistent with one it signed.
Returns the note.