Class Blocks

java.lang.Object
io.mokamint.node.Blocks

public abstract class Blocks extends Object
Providers of blocks.
  • Method Details

    • of

      public static NonGenesisBlock of(NonGenesisBlockDescription description, Stream<Transaction> transactions, byte[] stateId, PrivateKey privateKey) throws InvalidKeyException, SignatureException
      Yields a non-genesis block with the given description. It adds a signature to the resulting block, by using the signature algorithm in the prolog of the deadline and the given private key.
      Parameters:
      description - the description
      transactions - the transactions inside the block
      stateId - the identifier of the state of the application at the end of this block
      privateKey - the private key for signing the block
      Returns:
      the non-genesis block
      Throws:
      SignatureException - if the signature of the block failed
      InvalidKeyException - if the private key is invalid
    • genesis

      public static GenesisBlock genesis(GenesisBlockDescription description, byte[] stateId, PrivateKey privateKey) throws InvalidKeyException, SignatureException
      Yields a genesis block with the given description. It adds a signature to the resulting block, by using the signature algorithm specified in the description and the given private key.
      Parameters:
      description - the description of the block
      stateId - the identifier of the state of the application at the end of this block
      privateKey - the key used for signing the block
      Returns:
      the genesis block
      Throws:
      SignatureException - if the signature of the block failed
      InvalidKeyException - if the private key is invalid
    • from

      public static Block from(io.hotmoka.marshalling.api.UnmarshallingContext context, ConsensusConfig<?,?> config) throws IOException
      Unmarshals a block from the given context. It assumes that the block was marshalled by using Block.intoWithoutConfigurationData(io.hotmoka.marshalling.api.MarshallingContext).
      Parameters:
      context - the context
      config - the consensus configuration of the node storing the block description
      Returns:
      the block
      Throws:
      IOException - if the block cannot be unmarshalled
    • from

      public static Block from(io.hotmoka.marshalling.api.UnmarshallingContext context) throws IOException, NoSuchAlgorithmException
      Unmarshals a block from the given context. It assumes that the block was marshalled by using Marshallable.into(io.hotmoka.marshalling.api.MarshallingContext).
      Parameters:
      context - the context
      Returns:
      the block
      Throws:
      IOException - if the block cannot be unmarshalled
      NoSuchAlgorithmException - if the block refers to an unknown cryptographic algorithm