Class BlockHeader
Block header containing information about Blocks except transactions.
Inherited Members
Namespace: Libplanet.Types.Blocks
Assembly: Libplanet.Types.dll
Syntax
public sealed class BlockHeader : IBlockHeader, IPreEvaluationBlockHeader, IBlockMetadata, IBlockExcerpt
Constructors
| Improve this Doc View SourceBlockHeader(IBlockHeader)
Creates a BlockHeader by copying the fields of another
block header
.
Declaration
public BlockHeader(IBlockHeader header)
Parameters
Type | Name | Description |
---|---|---|
IBlockHeader | header | The block header to copy. |
Remarks
As header
needn't be an actual BlockHeader
instance, but simply any object implementing IBlockHeader
interface, it can't be trusted to satisfy all the constraints for a valid
BlockHeader instance. As such, conditions are checked again
whilst creating a copy. This is a relatively heavy operation, so must be used
sparingly.
In particular, this creates a new instance of
PreEvaluationBlockHeader with data extracted from
header
. Thus any Exceptions that can be thrown from a
PreEvaluationBlockHeader's constructors may also be thrown
in addition to the ones explicitly listed below.
Exceptions
Type | Condition |
---|---|
InvalidBlockSignatureException | Thrown if
|
InvalidBlockHashException | Thrown when |
See Also
| Improve this Doc View SourceBlockHeader(PreEvaluationBlockHeader, HashDigest<SHA256>, Nullable<ImmutableArray<Byte>>, BlockHash)
Creates a BlockHeader instance from the given
preEvaluationBlockHeader
and stateRootHash
.
It also checks the sanity of the given hash
.
Declaration
public BlockHeader(PreEvaluationBlockHeader preEvaluationBlockHeader, HashDigest<SHA256> stateRootHash, ImmutableArray<byte>? signature, BlockHash hash)
Parameters
Type | Name | Description |
---|---|---|
PreEvaluationBlockHeader | preEvaluationBlockHeader | The pre-evaluation block header. |
HashDigest<SHA256> | stateRootHash | The state root hash. |
Nullable<ImmutableArray<Byte>> | signature | The block signature. |
BlockHash | hash | The block hash to check. |
Exceptions
Type | Condition |
---|---|
InvalidBlockSignatureException | Thrown when
the |
InvalidBlockHashException | Thrown when the given block
|
BlockHeader(PreEvaluationBlockHeader, (HashDigest<SHA256> StateRootHash, Nullable<ImmutableArray<Byte>> Signature, BlockHash Hash))
Creates a BlockHeader instance with its
preEvaluationBlockHeader
and proof
.
Declaration
public BlockHeader(PreEvaluationBlockHeader preEvaluationBlockHeader, (HashDigest<SHA256> StateRootHash, ImmutableArray<byte>? Signature, BlockHash Hash) proof)
Parameters
Type | Name | Description |
---|---|---|
PreEvaluationBlockHeader | preEvaluationBlockHeader | The pre-evaluation block header. |
(T1 Item1, T2 Item2, T3 Item3)<HashDigest<SHA256>, Nullable<ImmutableArray<Byte>>, BlockHash> | proof | A triple of the state root hash, the block signature, and the block
hash which is probably considered as to be derived from
the |
Exceptions
Type | Condition |
---|---|
InvalidBlockSignatureException | Thrown if
|
InvalidBlockHashException | Thrown when |
Properties
| Improve this Doc View SourceHash
A block's hash.
Declaration
public BlockHash Hash { get; }
Property Value
Type | Description |
---|---|
BlockHash |
See Also
| Improve this Doc View SourceHeader
Internal PreEvaluationBlockHeader.
Declaration
public PreEvaluationBlockHeader Header { get; }
Property Value
Type | Description |
---|---|
PreEvaluationBlockHeader |
Index
The height of the block.
Declaration
public long Index { get; }
Property Value
Type | Description |
---|---|
Int64 |
Remarks
Zero means it is a genesis block. Not allowed to be negative.
See Also
| Improve this Doc View SourceLastCommit
Block header containing information about Blocks except transactions.
Declaration
public BlockCommit LastCommit { get; }
Property Value
Type | Description |
---|---|
BlockCommit |
Miner
The address of the miner.
Declaration
public Address Miner { get; }
Property Value
Type | Description |
---|---|
Address |
PreEvaluationHash
The hash derived from the block except of its state root hash (i.e., without action evaluation). Used for validating Nonce.
Declaration
public HashDigest<SHA256> PreEvaluationHash { get; }
Property Value
Type | Description |
---|---|
HashDigest<SHA256> |
See Also
| Improve this Doc View SourcePreviousHash
The previous block's hash. If it's a genesis block (i.e., its Index is 0) this must be null.
Declaration
public BlockHash? PreviousHash { get; }
Property Value
Type | Description |
---|---|
Nullable<BlockHash> |
ProtocolVersion
The protocol version number.
Declaration
public int ProtocolVersion { get; }
Property Value
Type | Description |
---|---|
Int32 |
See Also
| Improve this Doc View SourcePublicKey
The public key of the Miner. This is used for verifying the signature.
Although this is nullable type-wise, it is mandatory where ProtocolVersion is 2 or later. As blocks had not been signed in the previous protocol versions, the type of this is nullable.
Declaration
public PublicKey PublicKey { get; }
Property Value
Type | Description |
---|---|
PublicKey |
Signature
The digital signature of the whole block content (except for Hash, which is derived from the signature and other contents). This is made by the Miner's PrivateKey.
As the block signature is introduced since the protocol version 2, it is null for blocks with earlier protocol versions than 2. Although the property is type-wise, the block signature is mandatory since the protocol version 2.
Declaration
public ImmutableArray<byte>? Signature { get; }
Property Value
Type | Description |
---|---|
Nullable<ImmutableArray<Byte>> |
StateRootHash
The
Declaration
public HashDigest<SHA256> StateRootHash { get; }
Property Value
Type | Description |
---|---|
HashDigest<SHA256> |
Timestamp
The time the block is created.
Declaration
public DateTimeOffset Timestamp { get; }
Property Value
Type | Description |
---|---|
DateTimeOffset |
Remarks
This is always UTC.
TxHash
The hash of all transactions in the block. This is null if the block has no transactions.
Declaration
public HashDigest<SHA256>? TxHash { get; }
Property Value
Type | Description |
---|---|
Nullable<HashDigest<SHA256>> |
Methods
| Improve this Doc View SourceToString()
Block header containing information about Blocks except transactions.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |