Class BlockDescriptions

java.lang.Object
io.mokamint.node.BlockDescriptions

public abstract class BlockDescriptions extends Object
Providers of block descriptions.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Gson decoder.
    static class 
    Gson encoder.
    static class 
    Json representation.
  • Method Summary

    Modifier and Type
    Method
    Description
    from(io.hotmoka.marshalling.api.UnmarshallingContext context)
    Unmarshals a block description from the given context.
    from(io.hotmoka.marshalling.api.UnmarshallingContext context, ConsensusConfig<?,?> config)
    Unmarshals a block description from the given context.
    genesis(LocalDateTime startDateTimeUTC, int targetBlockCreationTime, int oblivion, io.hotmoka.crypto.api.HashingAlgorithm hashingForBlocks, io.hotmoka.crypto.api.HashingAlgorithm hashingForTransactions, io.hotmoka.crypto.api.HashingAlgorithm hashingForDeadlines, io.hotmoka.crypto.api.HashingAlgorithm hashingForGenerations, io.hotmoka.crypto.api.SignatureAlgorithm signatureForBlocks, PublicKey publicKey)
    Yields a new genesis block description.
    of(long height, BigInteger power, long totalWaitingTime, long weightedWaitingTime, BigInteger acceleration, io.mokamint.nonce.api.Deadline deadline, byte[] hashOfPreviousBlock, int targetBlockCreationTime, int oblivion, io.hotmoka.crypto.api.HashingAlgorithm hashingForBlocks, io.hotmoka.crypto.api.HashingAlgorithm hashingForTransactions)
    Yields a new non-genesis block description.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • of

      public static NonGenesisBlockDescription of(long height, BigInteger power, long totalWaitingTime, long weightedWaitingTime, BigInteger acceleration, io.mokamint.nonce.api.Deadline deadline, byte[] hashOfPreviousBlock, int targetBlockCreationTime, int oblivion, io.hotmoka.crypto.api.HashingAlgorithm hashingForBlocks, io.hotmoka.crypto.api.HashingAlgorithm hashingForTransactions)
      Yields a new non-genesis block description.
      Parameters:
      height - the block height, positive, since 0 is the height of the genesis block
      power - the power of the block, computed as the sum, for each block from genesis to the block, of 2^(hashing bits) / (value of the deadline in the block + 1). This allows one to compare forks and choose the one whose tip has the highest power. Intuitively, the power expresses the space used to compute the chain leading to the block
      totalWaitingTime - the total waiting time between the creation of the genesis block and the creation of the block
      weightedWaitingTime - the weighted waiting time between the creation of the genesis block and the creation of the 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 the block
      hashOfPreviousBlock - the reference to the previous block
      targetBlockCreationTime - the target time for the creation of the blocks, in milliseconds
      oblivion - the rapidity of changes of acceleration. It is a value between 0 (no acceleration change) to 100,000 (maximally fast change)
      hashingForBlocks - the hashing algorithm used for the blocks
      hashingForTransactions - the hashing algorithm used for the transactions in the block
      Returns:
      the non-genesis block description
    • genesis

      public static GenesisBlockDescription genesis(LocalDateTime startDateTimeUTC, int targetBlockCreationTime, int oblivion, io.hotmoka.crypto.api.HashingAlgorithm hashingForBlocks, io.hotmoka.crypto.api.HashingAlgorithm hashingForTransactions, io.hotmoka.crypto.api.HashingAlgorithm hashingForDeadlines, io.hotmoka.crypto.api.HashingAlgorithm hashingForGenerations, io.hotmoka.crypto.api.SignatureAlgorithm signatureForBlocks, PublicKey publicKey) throws InvalidKeyException
      Yields a new genesis block description.
      Parameters:
      startDateTimeUTC - the moment when the block has been created
      targetBlockCreationTime - the target time for the creation of the blocks, in milliseconds
      oblivion - the rapidity of changes of acceleration. It is a value between 0 (no acceleration change) to 100,000 (maximally fast change)
      hashingForBlocks - the hashing algorithm used for the blocks
      hashingForTransactions - the hashing algorithm used for the transactions in the block
      hashingForDeadlines - the hashing algorithm used for the deadlines
      hashingForGenerations - the hashing algorithm used for the generation signatures
      signatureForBlocks - the signature algorithm for the blocks
      publicKey - the public key of the signer of the block
      Returns:
      the genesis block description
      Throws:
      InvalidKeyException - if the public key is invalid
    • from

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

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