• Design
  • API Reference
  • Changelog
  • Contribute
Show / Hide Table of Contents
  • Libplanet
    • Address
    • AddressExtension
    • ByteUtil
    • Hashcash
    • Hashcash.Stamp
    • HashDigest<T>
    • HashDigestExtension
    • Nonce
  • Libplanet.Action
    • AccountStateGetter
    • ActionEvaluation<T>
    • ActionTypeAttribute
    • AddressStateMap
    • IAccountStateDelta
    • IAction
    • IActionContext
    • IRandom
    • MissingActionTypeException
    • PolymorphicAction<T>
  • Libplanet.Blockchain
    • BlockChain<T>
  • Libplanet.Blockchain.Policies
    • BlockPolicy<T>
    • BlockPolicyExtension
    • IBlockPolicy<T>
  • Libplanet.Blocks
    • Block<T>
    • InvalidBlockDifficultyException
    • InvalidBlockException
    • InvalidBlockHashException
    • InvalidBlockIndexException
    • InvalidBlockNonceException
    • InvalidBlockPreviousHashException
    • InvalidBlockTimestampException
  • Libplanet.Crypto
    • InvalidCiphertextException
    • PrivateKey
    • PublicKey
    • SymmetricKey
  • Libplanet.Net
    • BlockDownloadState
    • DifferentAppProtocolVersionException
    • DifferentProtocolVersionEventArgs
    • IceServer
    • IceServerException
    • InvalidMessageException
    • NoSwarmContextException
    • Peer
    • PeerNotFoundException
    • PeerSetDelta
    • Swarm
    • SwarmException
  • Libplanet.Serialization
    • BencodexFormatter<T>
    • SerializationInfoExtension
  • Libplanet.Store
    • BaseIndex<TKey, TVal>
    • BaseStore
    • BlockSet<T>
    • FileStore
    • IStore
    • NamespaceNotFoundException
    • TransactionSet<T>
  • Libplanet.Tx
    • InvalidTxException
    • InvalidTxIdException
    • InvalidTxNonceException
    • InvalidTxPublicKeyException
    • InvalidTxSignatureException
    • InvalidTxUpdatedAddressesException
    • Transaction<T>
    • TxId
    • UnexpectedlyTerminatedTxRehearsalException

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
[Equals]
public class Block<T> : ISerializable where T : IAction, new()
Type Parameters
Name Description
T

Constructors

| Improve this Doc View Source

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

Declaration
public Block(long index, long difficulty, Nonce nonce, Address? miner, HashDigest<SHA256>? previousHash, DateTimeOffset timestamp, IEnumerable<Transaction<T>> transactions)
Parameters
Type Name Description
Int64 index
Int64 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
[IgnoreDuringEquals]
public long Difficulty { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

Hash

Declaration
public HashDigest<SHA256> Hash { get; }
Property Value
Type Description
HashDigest<SHA256>
| Improve this Doc View Source

Index

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

Miner

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

Nonce

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

PreviousHash

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

Timestamp

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

Transactions

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

Methods

| Improve this Doc View Source

Evaluate(DateTimeOffset, AccountStateGetter)

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

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

Otherwise it enumerates an ActionEvaluation<T> for each IAction.

Declaration
public IEnumerable<ActionEvaluation<T>> Evaluate(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
IEnumerable<ActionEvaluation<T>>

An ActionEvaluation<T> for each IAction.

Exceptions
Type Condition
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.

| Improve this Doc View Source

EvaluateActionsPerTx(AccountStateGetter)

Executes every IAction in the Transactions step by step, and emits a pair of a transaction, and an ActionEvaluation<T> for each step.

Declaration
[Pure]
public IEnumerable<(Transaction<T>, ActionEvaluation<T>)> EvaluateActionsPerTx(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<ValueTuple<Transaction<T>, ActionEvaluation<T>>>

Enumerates pair of a transaction, and ActionEvaluation<T> for each action. The order of pairs are the same to the Transactions and their Actions (e.g., tx¹-act¹, tx¹-act², tx²-act¹, tx²-act², …). Note that each Random object has a unconsumed state.

| 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, Int64, Address, Nullable<HashDigest<SHA256>>, DateTimeOffset, IEnumerable<Transaction<T>>)

Declaration
public static Block<T> Mine(long index, long difficulty, Address miner, HashDigest<SHA256>? previousHash, DateTimeOffset timestamp, IEnumerable<Transaction<T>> transactions)
Parameters
Type Name Description
Int64 index
Int64 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()

Implements

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