pub struct Chain {
pub blocks: Vec<Block>,
}Expand description
An append-only chain of post-quantum-signed blocks.
Fields§
§blocks: Vec<Block>Implementations§
Source§impl Chain
impl Chain
Sourcepub fn genesis(
founder: &Probe,
timestamp: u64,
beacon: impl Into<String>,
) -> Self
pub fn genesis( founder: &Probe, timestamp: u64, beacon: impl Into<String>, ) -> Self
Create a new chain, proposing the genesis (“Big Bang”) block with founder.
Sourcepub fn draft(
&self,
proposer: &Probe,
timestamp: u64,
beacon: impl Into<String>,
transactions: Vec<Transaction>,
) -> Block
pub fn draft( &self, proposer: &Probe, timestamp: u64, beacon: impl Into<String>, transactions: Vec<Transaction>, ) -> Block
Build and post-quantum-sign the next block without appending it.
Lets a proposer broadcast the exact block it will append. The block links to the
current head (or BIG_BANG if the chain is empty).
Sourcepub fn try_append(&mut self, block: Block) -> Result<(), ChainError>
pub fn try_append(&mut self, block: Block) -> Result<(), ChainError>
Validate a block against the current head (index, link, hash, proposer fingerprint, PQC signature) and append it. Does not enforce consensus rules (who may propose) — that is the node layer’s job.
Sourcepub fn propose(
&mut self,
proposer: &Probe,
timestamp: u64,
beacon: impl Into<String>,
transactions: Vec<Transaction>,
) -> u64
pub fn propose( &mut self, proposer: &Probe, timestamp: u64, beacon: impl Into<String>, transactions: Vec<Transaction>, ) -> u64
Propose (draft + append) the next block with proposer. Returns its index.
Sourcepub fn verify(&self) -> Result<(), ChainError>
pub fn verify(&self) -> Result<(), ChainError>
Verify the entire chain: links, hashes, and every post-quantum signature.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn head(&self) -> Option<&Block>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chain
impl RefUnwindSafe for Chain
impl Send for Chain
impl Sync for Chain
impl Unpin for Chain
impl UnsafeUnpin for Chain
impl UnwindSafe for Chain
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