Show / Hide Table of Contents

Class Block<T>

Inheritance
Object
Block<T>
Implements
ISerializable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Namespace: Libplanet.Blocks
Assembly: Libplanet.dll
Syntax
[GeneratedEquality]
public class Block<T> : ISerializable where T : IAction, new()
Type Parameters
Name Description
T

Constructors

| Improve this Doc View Source

Block(Int64, Int32, Nonce, Nullable<Address>, Nullable<HashDigest<SHA256>>, DateTimeOffset, IEnumerable<Transaction<T>>)

Declaration
public Block(long index, int difficulty, Nonce nonce, Address? miner, HashDigest<SHA256>? previousHash, DateTimeOffset timestamp, IEnumerable<Transaction<T>> transactions)
Parameters
Type Name Description
Int64 index
Int32 difficulty
Nonce nonce
Nullable<Address> miner
Nullable<HashDigest<SHA256>> previousHash
DateTimeOffset timestamp
IEnumerable<Transaction<T>> transactions
| Improve this Doc View Source

Block(SerializationInfo, StreamingContext)

Declaration
protected Block(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context

Properties

| Improve this Doc View Source

Difficulty

Declaration
[EqualityIgnore]
public int Difficulty { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

Hash

Declaration
[EqualityKey(KeyEqualityMode.Auto)]
public HashDigest<SHA256> Hash { get; }
Property Value
Type Description
HashDigest<SHA256>
| Improve this Doc View Source

Index

Declaration
[EqualityIgnore]
public long Index { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

Miner

Declaration
[EqualityIgnore]
public Address? Miner { get; }
Property Value
Type Description
Nullable<Address>
| Improve this Doc View Source

Nonce

Declaration
[EqualityIgnore]
public Nonce Nonce { get; }
Property Value
Type Description
Nonce
| Improve this Doc View Source

PreviousHash

Declaration
[EqualityIgnore]
public HashDigest<SHA256>? PreviousHash { get; }
Property Value
Type Description
Nullable<HashDigest<SHA256>>
| Improve this Doc View Source

Timestamp

Declaration
[EqualityIgnore]
public DateTimeOffset Timestamp { get; }
Property Value
Type Description
DateTimeOffset
| Improve this Doc View Source

Transactions

Declaration
[EqualityIgnore]
public IEnumerable<Transaction<T>> Transactions { get; }
Property Value
Type Description
IEnumerable<Transaction<T>>

Methods

| Improve this Doc View Source

EvaluateActions(AccountStateGetter)

Executes every IAction in the Transactions and gets result states of each step of every Transaction<T>.

Declaration
[Pure]
public IEnumerable<IAccountStateDelta> EvaluateActions(AccountStateGetter accountStateGetter = null)
Parameters
Type Name Description
AccountStateGetter accountStateGetter

An AccountStateGetter delegate to get a previous state. A null value, which is default, means a constant function that returns null.

Returns
Type Description
IEnumerable<IAccountStateDelta>

Result states of immediately after IActions in each Transaction<T> being executed.

| Improve this Doc View Source

FromBencodex(Byte[])

Declaration
public static Block<T> FromBencodex(byte[] encoded)
Parameters
Type Name Description
Byte[] encoded
Returns
Type Description
Block<T>
| Improve this Doc View Source

GetObjectData(SerializationInfo, StreamingContext)

Declaration
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context
| Improve this Doc View Source

Mine(Int64, Int32, Address, Nullable<HashDigest<SHA256>>, DateTimeOffset, IEnumerable<Transaction<T>>)

Declaration
public static Block<T> Mine(long index, int difficulty, Address miner, HashDigest<SHA256>? previousHash, DateTimeOffset timestamp, IEnumerable<Transaction<T>> transactions)
Parameters
Type Name Description
Int64 index
Int32 difficulty
Address miner
Nullable<HashDigest<SHA256>> previousHash
DateTimeOffset timestamp
IEnumerable<Transaction<T>> transactions
Returns
Type Description
Block<T>
| Improve this Doc View Source

ToBencodex(Boolean, Boolean)

Declaration
public byte[] ToBencodex(bool hash, bool transactionData)
Parameters
Type Name Description
Boolean hash
Boolean transactionData
Returns
Type Description
Byte[]
| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()
| Improve this Doc View Source

Validate(DateTimeOffset, AccountStateGetter)

Validates the integrity of the Block<T>.

It throws an InvalidBlockException or an InvalidTxException if there is any integrity error.

Otherwise it returns an IAccountStateDelta which represents the final states and maintains the changes from the states of the previous Block<T>.

Declaration
public IAccountStateDelta Validate(DateTimeOffset currentTime, AccountStateGetter accountStateGetter)
Parameters
Type Name Description
DateTimeOffset currentTime

The current time to validate time-wise conditions.

AccountStateGetter accountStateGetter

The getter of previous states. This affects the execution of Actions.

Returns
Type Description
IAccountStateDelta

An IAccountStateDelta of the states right after all Actions of Transactions, which maintains the changes from the states of the previous Block<T>.

Exceptions
Type Condition
Libplanet.Blocks.InvalidBlockTimestampException

Thrown when the Timestamp is invalid, for example, it is the far future than the given currentTime.

InvalidBlockIndexException

Thrown when the Indexis invalid, for example, it is a negative integer.

InvalidBlockDifficultyException

Thrown when the Difficulty is not properly configured, for example, it is too easy.

InvalidBlockPreviousHashException

Thrown when PreviousHash is invalid so that the Block<T>s are not continuous.

InvalidBlockNonceException

Thrown when the Nonce does not satisfy its Difficulty level.

InvalidTxSignatureException

Thrown when its Signature is invalid or not signed by the account who corresponds to its PublicKey.

InvalidTxPublicKeyException

Thrown when its Signer is not derived from its PublicKey.

InvalidTxUpdatedAddressesException

Thrown when any IAction of Transactions tries to update the states of Addresses not included in UpdatedAddresses.

Implements

System.Runtime.Serialization.ISerializable
  • Improve this Doc
  • View Source
Back to top Copyright © 2019 Planetarium
Generated by DocFX