Module type Block.BlockSig

The signature for a block module.

type block_contents

The user-defined contents of a block.

type block = block_contents t

The type of the block. Application of block_contents to t.

val create : node_id -> block -> block_contents -> block

Create a new block.

  • parameter node_id

    the id of the minter

  • parameter block

    the parent block

  • parameter block_contents

    the content for the new block

val null : block_contents -> block

Returns the null block

val height : 'a t -> int

Returns the height of a block.

  • parameter block

    a block

val parent : 'a t -> node_id option

Returns the parent of a block.

  • parameter block

    a block

val minter : 'a t -> node_id

Returns the id of the node that minted the block.

  • parameter block

    the block whose minter we want

val id : 'a t -> block_id

Return the id of a block given block.

  • parameter block

    the block whose id we want

val opt_id : 'a t option -> block_id

Return the id of a block option. Returns -1 if NONE.

  • parameter block_opt

    SOME(block) or NONE

val balances : 'a t -> balances

Return the balances contained in a block.

  • parameter block

    a block

val timestamp : 'a t -> Clock.t

Return the timestamp of the block's creation.

  • parameter block

    a block

val difficulty : 'a t -> int

Return the difficulty of the block.

  • parameter block

    a block

val total_difficulty : 'a t -> int

Return the total difficulty of the chain.

  • parameter block

    the head of the chain

val total_coins : 'a t -> float

Return the total amount of coins.

  • parameter block

    the head of the chain

val genesis_pow : node_id -> int -> block_contents -> block

Return the genesis block for PoW.

  • parameter node_id

    placeholder minter

  • parameter difficulty

    the initial difficulty

  • parameter contents

    the contents to be included in the genesis block

val genesis_pos : node_id -> block_contents -> block

Return the genesis block for PoS.

  • parameter node_id

    placeholder minter

  • parameter contents

    the contents to be included in the genesis block

val equals : 'a t -> 'a t -> bool

Check if two blocks are equal (have the same ID).

  • parameter block1

    a block

  • parameter block2

    another block