Module type Protocol.BlockchainNode

Extension of the base node, for blockchain protocols.

include AbstractNode
type value

The type of the values for which consensus is being reached.

type ev

The type of the events being handled.

type node_data

The protocol specific data stored by the node.

type t = (node_datavalue) template

The type representing a node and its state. Consists of apllying the value and node_data to the template.

Create the initial state of a node.

  • parameter node_id

    the id to be assigned to the node

  • parameter neighbors

    the node's neighbors

  • parameter region

    the node's region

val handle : t -> ev -> t

Receives the state of a node and an event, returning the resulting state.

  • parameter node

    the state of a node

  • parameter event

    the event to be processed by the node

val compare : t -> t -> int

Compares two nodes. Returns whether they are in the same state.

  • parameter node1

    the state of a node

  • parameter node2

    the state of a node

val state : t -> value

Get the consensus target of a node.

  • parameter node

    the state of a node

val state_id : t -> int

Return an integer that identifies the state of the node.

  • parameter node

    the state of a node

val parameters : unit -> string

Return a JSON string containing the relevant parameters (and values) for the Node's consensus algorithm

val chain_height : t -> int

Obtain the height of the chain stored in the node.

  • parameter node

    the state of a node