Skip to main content

FileJournal

Struct FileJournal 

Source
pub struct FileJournal { /* private fields */ }
Expand description

An append-only file of JSON lines, one entry per line, fsynced after every write.

§Durability, exactly

  • On open the file is validated. Every \n-terminated line must be an entry; a malformed terminated line is an error (a journal that cannot be read is not a journal, and a signer without one does not sign). An unterminated suffix is a torn write from a crash: if it parses as a whole entry only its newline was lost, and it is terminated; otherwise it is cut back to the last record boundary. The repair is synced, as is the directory after the file is created.
  • record appends after that boundary and syncs. If the append fails part-way the file is cut back to the length it had immediately before this write, measured on the file itself, never to a length cached earlier (a cached length rolled back other writers’ acknowledged entries; found by the 2026-09-22 verification pass); if even that fails the journal refuses every later write, so a torn line can never have another record appended to it.
  • One writer per file. open takes an exclusive advisory lock (flock) for the handle’s lifetime and a second live handle is refused by name (Error::Journal, “held by another handle”), so two rounds cannot share one file and roll each other back. The block round and the peg-out round each own their own journal.
  • A torn record was never acknowledged, so nothing was signed on its strength: the intent is written before the custody signer is asked.

Implementations§

Source§

impl FileJournal

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open or create path, creating its directory, validating the file and repairing a torn tail (see the type’s documentation).

Source

pub fn path(&self) -> &Path

Where it lives.

Trait Implementations§

Source§

impl Debug for FileJournal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl VoteJournal for FileJournal

Source§

fn record(&mut self, entry: &VoteEntry) -> Result<()>

Write an entry durably. Returning an error means the signer does not sign (for an intent) or does not publish (for a signature).
Source§

fn entries(&self) -> Result<Vec<VoteEntry>>

Every entry, oldest first.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V