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>
impl<F: HeaderFamily> ChainOf<F>
Sourcepub fn open(
doc: ChainDocument,
dir: impl AsRef<Path>,
key: Option<&SecretKey>,
) -> Result<Self>
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.
Sourcepub fn open_sealed(
doc: ChainDocument,
dir: impl AsRef<Path>,
seal: impl FnOnce(&F::Block) -> Result<F::Block>,
) -> Result<Self>
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.
Sourcepub fn index_path(&self) -> PathBuf
pub fn index_path(&self) -> PathBuf
dir/blocks.json.
Sourcepub fn add_block(
&mut self,
bytes: &[u8],
expect: Option<BlockHash>,
) -> Result<Applied>
pub fn add_block( &mut self, bytes: &[u8], expect: Option<BlockHash>, ) -> Result<Applied>
Accept a block from elsewhere (a mirror): validated, applied, written.
Trait Implementations§
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>
impl<F> Unpin for ChainOf<F>
impl<F> UnsafeUnpin for ChainOf<F>where
StateOf<F>: UnsafeUnpin,
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