pub trait Block: Serialize {
    type Id: BlockId;
    type Date: BlockDate;
    type Version;
    type ChainLength: ChainLength;

    // Required methods
    fn id(&self) -> Self::Id;
    fn parent_id(&self) -> Self::Id;
    fn date(&self) -> Self::Date;
    fn version(&self) -> Self::Version;
    fn chain_length(&self) -> Self::ChainLength;
}
Expand description

Block property

a block is part of a chain of block called Blockchain. the chaining is done via one block pointing to another block, the parent block (the previous block).

This means that a blockchain is a link-list, ordered from the most recent block to the furthest/oldest block.

The Oldest block is called the Genesis Block. TODO: add a Readable trait bound

Required Associated Types§

source

type Id: BlockId

the Block identifier. It must be unique. This mean that 2 different blocks have 2 different identifiers.

In bitcoin this block is a SHA2 256bits. For Cardano’s blockchain it is Blake2b 256bits.

source

type Date: BlockDate

the block date (also known as a block number) represents the absolute position of the block in the chain. This can be used for random access (if the storage algorithm allows it) or for identifying the position of a block in a given epoch or era.

source

type Version

the type associated to the version of a block

source

type ChainLength: ChainLength

the length of the blockchain (number of blocks)

Required Methods§

source

fn id(&self) -> Self::Id

return the Block’s identifier.

source

fn parent_id(&self) -> Self::Id

get the parent block identifier (the previous block in the blockchain).

source

fn date(&self) -> Self::Date

get the block date of the block

source

fn version(&self) -> Self::Version

access the version of a given block

source

fn chain_length(&self) -> Self::ChainLength

get the block’s chain length. The number of block created following this thread of blocks on the blockchain (including Self).

Implementors§