java.lang.Object
io.mokamint.node.BlockDescriptions
Providers of block descriptions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGson decoder.static classGson encoder.static classJson representation. -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockDescriptionfrom(io.hotmoka.marshalling.api.UnmarshallingContext context) Unmarshals a block description from the given context.static BlockDescriptionfrom(io.hotmoka.marshalling.api.UnmarshallingContext context, ConsensusConfig<?, ?> config) Unmarshals a block description from the given context.static GenesisBlockDescriptiongenesis(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.static NonGenesisBlockDescriptionof(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.
-
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 blockpower- 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 blocktotalWaitingTime- the total waiting time between the creation of the genesis block and the creation of the blockweightedWaitingTime- the weighted waiting time between the creation of the genesis block and the creation of the 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 the blockhashOfPreviousBlock- the reference to the previous blocktargetBlockCreationTime- the target time for the creation of the blocks, in millisecondsoblivion- 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 blockshashingForTransactions- 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 createdtargetBlockCreationTime- the target time for the creation of the blocks, in millisecondsoblivion- 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 blockshashingForTransactions- the hashing algorithm used for the transactions in the blockhashingForDeadlines- the hashing algorithm used for the deadlineshashingForGenerations- the hashing algorithm used for the generation signaturessignatureForBlocks- the signature algorithm for the blockspublicKey- 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 IOExceptionUnmarshals a block description from the given context. It assumes that the description was marshalled by usingBlockDescription.intoWithoutConfigurationData(io.hotmoka.marshalling.api.MarshallingContext).- Parameters:
context- the contextconfig- 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 usingMarshallable.into(io.hotmoka.marshalling.api.MarshallingContext).- Parameters:
context- the context- Returns:
- the block description
- Throws:
IOException- if the block description cannot be unmarshalledNoSuchAlgorithmException- if the block description refers to an unknown cryptographic algorithm
-