Skip to main content

ChainOf

Struct ChainOf 

Source
pub struct ChainOf<F: HeaderFamily> { /* private fields */ }
Expand description

The chain with its block file, for header family F.

Implementations§

Source§

impl<F: HeaderFamily> ChainOf<F>

Source

pub fn open( doc: ChainDocument, dir: impl AsRef<Path>, key: Option<&SecretKey>, ) -> Result<Self>

Replay dir/blocks.dat, creating it with the genesis when absent — which needs the signer’s key. open() refuses a block file whose block 0 does not hash to the document’s genesisHash, and any later block the rules refuse.

Source

pub fn open_sealed( doc: ChainDocument, dir: impl AsRef<Path>, seal: impl FnOnce(&F::Block) -> Result<F::Block>, ) -> Result<Self>

ChainOf::open for a federated chain (siding/lib/chain.mjs open(null, { seal })): when no chain is on disk, seal receives the unsigned genesis (StateOf::build_genesis_for) and returns it sealed by k signatures — crate::federation::seal_federated with the partials the signers made. With a chain on disk, seal is not called.

Source

pub fn state(&self) -> &StateOf<F>

The chain in memory.

Source

pub fn index(&self) -> &Index

The block file’s index.

Source

pub fn dat_path(&self) -> PathBuf

dir/blocks.dat.

Source

pub fn index_path(&self) -> PathBuf

dir/blocks.json.

Source

pub fn add_block( &mut self, bytes: &[u8], expect: Option<BlockHash>, ) -> Result<Applied>

Accept a block from elsewhere (a mirror): validated, applied, written.

Source

pub fn submit(&mut self, tx_bytes: &[u8]) -> Result<Submitted>

A transaction for the mempool (SPEC 11), consensus bytes.

Source

pub fn produce( &mut self, key: &SecretKey, claims: Vec<ClaimRequest>, ) -> Result<Applied>

One signer: build the next block from the mempool and these claims, sign, apply, write.

Trait Implementations§

Source§

impl<F: Debug + HeaderFamily> Debug for ChainOf<F>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> !RefUnwindSafe for ChainOf<F>

§

impl<F> !Send for ChainOf<F>

§

impl<F> !Sync for ChainOf<F>

§

impl<F> !UnwindSafe for ChainOf<F>

§

impl<F> Freeze for ChainOf<F>
where StateOf<F>: Freeze,

§

impl<F> Unpin for ChainOf<F>
where StateOf<F>: Unpin,

§

impl<F> UnsafeUnpin for ChainOf<F>
where StateOf<F>: UnsafeUnpin,

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<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, 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.