Struct miden_objects::block::Block
source · pub struct Block { /* private fields */ }Expand description
A block in the Miden chain.
A block contains information resulting from executing a set of transactions against the chain state defined by the previous block. It consists of 3 main components:
- A set of change descriptors for all accounts updated in this block. For private accounts, the block contains only the new account state hashes; for public accounts, the block also contains a set of state deltas which can be applied to the previous account state to get the new account state.
- A set of new notes created in this block. For private notes, the block contains only note IDs and note metadata; for public notes, full note details are recorded.
- A set of new nullifiers created for all notes that were consumed in the block.
In addition to the above components, a block also contains a block header which contains commitments to the new state of the chain as well as a ZK proof attesting that a set of valid transactions was executed to transition the chain into the state described by this block (the ZK proof part is not yet implemented).
Implementations§
source§impl Block
impl Block
sourcepub fn new(
header: BlockHeader,
updated_accounts: Vec<BlockAccountUpdate>,
created_notes: Vec<NoteBatch>,
created_nullifiers: Vec<Nullifier>
) -> Result<Self, BlockError>
pub fn new( header: BlockHeader, updated_accounts: Vec<BlockAccountUpdate>, created_notes: Vec<NoteBatch>, created_nullifiers: Vec<Nullifier> ) -> Result<Self, BlockError>
Returns a new Block instantiated from the provided components.
Note: consistency of the provided components is not validated.
sourcepub fn header(&self) -> BlockHeader
pub fn header(&self) -> BlockHeader
Returns the header of this block.
sourcepub fn updated_accounts(&self) -> &[BlockAccountUpdate]
pub fn updated_accounts(&self) -> &[BlockAccountUpdate]
Returns a set of account update descriptions for all accounts updated in this block.
sourcepub fn created_notes(&self) -> &[NoteBatch]
pub fn created_notes(&self) -> &[NoteBatch]
Returns a set of note batches containing all notes created in this block.
sourcepub fn notes(&self) -> impl Iterator<Item = (BlockNoteIndex, &OutputNote)>
pub fn notes(&self) -> impl Iterator<Item = (BlockNoteIndex, &OutputNote)>
Returns an iterator over all notes created in this block.
Each note is accompanied by a corresponding index specifying where the note is located in the blocks note tree.
sourcepub fn build_note_tree(&self) -> BlockNoteTree
pub fn build_note_tree(&self) -> BlockNoteTree
Returns a note tree containing all notes created in this block.
sourcepub fn created_nullifiers(&self) -> &[Nullifier]
pub fn created_nullifiers(&self) -> &[Nullifier]
Returns a set of nullifiers for all notes consumed in the block.
Trait Implementations§
source§impl Deserializable for Block
impl Deserializable for Block
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl Serializable for Block
impl Serializable for Block
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.