public interface Blocks
Providers of blocks.
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic Blockfrom(byte[] bytes) Unmarshals a block from the given bytes.static Blockfrom(io.hotmoka.marshalling.api.UnmarshallingContext context) Unmarshals a block from the given context.static GenesisBlockgenesis(LocalDateTime startDateTimeUTC) Yields a new genesis block.static NonGenesisBlockof(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 blocktotalWaitingTime- the total waiting time between the creation of the genesis block and the creation of this blockweightedWaitingTime- the weighted waiting time between the creation of the genesis block and the creation of this blockacceleration- 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 difficultydeadline- the deadline computed for this blockhashOfPreviousBlock- the reference to the previous block- Returns:
- the non-genesis block
-
genesis
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 unknownIOException- if the block cannot be unmarshalled
-
from
Unmarshals a block from the given bytes.- Parameters:
bytes- the bytes- Returns:
- the block
- Throws:
NoSuchAlgorithmException- if the hashing algorithm of the block is unknownIOException- if the block could not be unmarshalled
-