Interface Blocks


public interface Blocks
Providers of blocks.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static Block
    from(byte[] bytes)
    Unmarshals a block from the given bytes.
    static Block
    from(io.hotmoka.marshalling.api.UnmarshallingContext context)
    Unmarshals a block from the given context.
    genesis(LocalDateTime startDateTimeUTC)
    Yields a new genesis block.
    of(long height, long totalWaitingTime, long weightedWaitingTime, BigInteger acceleration, io.mokamint.nonce.api.Deadline deadline, byte[] hashOfPreviousBlock)
    Yields a new non-genesis block.
  • Method Details

    • of

      static NonGenesisBlock of(long height, long totalWaitingTime, long weightedWaitingTime, BigInteger acceleration, io.mokamint.nonce.api.Deadline deadline, byte[] hashOfPreviousBlock)
      Yields a new non-genesis block.
      Parameters:
      height - the block height, non-negative, counting from 0, which is the genesis block
      totalWaitingTime - the total waiting time between the creation of the genesis block and the creation of this block
      weightedWaitingTime - the weighted waiting time between the creation of the genesis block and the creation of this block
      acceleration - a value used to divide the deadline to derive the time needed to wait for it. The higher, the shorter the time. This value changes dynamically to cope with varying mining power in the network. It is the inverse of Bitcoin's difficulty
      deadline - the deadline computed for this block
      hashOfPreviousBlock - the reference to the previous block
      Returns:
      the non-genesis block
    • genesis

      static GenesisBlock genesis(LocalDateTime startDateTimeUTC)
      Yields a new genesis block.
      Parameters:
      startDateTimeUTC - the moment when the block has been created
      Returns:
      the genesis block
    • from

      static Block from(io.hotmoka.marshalling.api.UnmarshallingContext context) throws NoSuchAlgorithmException, IOException
      Unmarshals a block from the given context.
      Parameters:
      context - the context
      Returns:
      the block
      Throws:
      NoSuchAlgorithmException - if the hashing algorithm of the block is unknown
      IOException - if the block cannot be unmarshalled
    • from

      static Block from(byte[] bytes) throws NoSuchAlgorithmException, IOException
      Unmarshals a block from the given bytes.
      Parameters:
      bytes - the bytes
      Returns:
      the block
      Throws:
      NoSuchAlgorithmException - if the hashing algorithm of the block is unknown
      IOException - if the block could not be unmarshalled