• 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 BlockChain<T>

Inheritance
Object
BlockChain<T>
Implements
IReadOnlyList<Block<T>>
IReadOnlyCollection<Block<T>>
IEnumerable<Block<T>>
IEnumerable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Blockchain
Assembly: Libplanet.dll
Syntax
public class BlockChain<T> : IReadOnlyList<Block<T>>, IReadOnlyCollection<Block<T>>, IEnumerable<Block<T>>, IEnumerable where T : IAction, new()
Type Parameters
Name Description
T

Constructors

| Improve this Doc View Source

BlockChain(IBlockPolicy<T>, IStore)

Declaration
public BlockChain(IBlockPolicy<T> policy, IStore store)
Parameters
Type Name Description
IBlockPolicy<T> policy
IStore store
| Improve this Doc View Source

BlockChain(IBlockPolicy<T>, IStore, Guid)

Declaration
public BlockChain(IBlockPolicy<T> policy, IStore store, Guid id)
Parameters
Type Name Description
IBlockPolicy<T> policy
IStore store
Guid id

Properties

| Improve this Doc View Source

Blocks

All Block<T>s in the BlockChain<T> storage, including orphan Block<T>s. Keys are Hashes and values are their corresponding Block<T>s.

Declaration
public IDictionary<HashDigest<SHA256>, Block<T>> Blocks { get; }
Property Value
Type Description
IDictionary<HashDigest<SHA256>, Block<T>>
| Improve this Doc View Source

Id

Declaration
public Guid Id { get; }
Property Value
Type Description
Guid
| Improve this Doc View Source

Item[Int32]

Declaration
public Block<T> this[int index] { get; }
Parameters
Type Name Description
Int32 index
Property Value
Type Description
Block<T>
| Improve this Doc View Source

Item[Int64]

Declaration
public Block<T> this[long index] { get; }
Parameters
Type Name Description
Int64 index
Property Value
Type Description
Block<T>
| Improve this Doc View Source

Policy

Declaration
public IBlockPolicy<T> Policy { get; }
Property Value
Type Description
IBlockPolicy<T>
| Improve this Doc View Source

Tip

Declaration
public Block<T> Tip { get; }
Property Value
Type Description
Block<T>
| Improve this Doc View Source

Transactions

All Transaction<T>s in the BlockChain<T> storage, including orphan Transaction<T>s. Keys are Ids and values are their corresponding Transaction<T>s.

Declaration
public IDictionary<TxId, Transaction<T>> Transactions { get; }
Property Value
Type Description
IDictionary<TxId, Transaction<T>>

Methods

| Improve this Doc View Source

Append(Block<T>)

Adds a block to the end of this chain.

Note that Render(IActionContext, IAccountStateDelta) methods of all IAction objects that belong to the block are called right after the block is confirmed (and thus all states reflect changes in the block).

Declaration
public void Append(Block<T> block)
Parameters
Type Name Description
Block<T> block

A next Block<T>, which is mined, to add.

Exceptions
Type Condition
InvalidBlockException

Thrown when the given block is invalid, in itself or according to the Policy.

InvalidTxNonceException

Thrown when the Nonce is different from GetNonce(Address) result of the Signer.

| Improve this Doc View Source

Append(Block<T>, DateTimeOffset)

Adds a block to the end of this chain.

Note that Render(IActionContext, IAccountStateDelta) methods of all IAction objects that belong to the block are called right after the block is confirmed (and thus all states reflect changes in the block).

Declaration
public void Append(Block<T> block, DateTimeOffset currentTime)
Parameters
Type Name Description
Block<T> block

A next Block<T>, which is mined, to add.

DateTimeOffset currentTime

The current time.

Exceptions
Type Condition
InvalidBlockException

Thrown when the given block is invalid, in itself or according to the Policy.

InvalidTxNonceException

Thrown when the Nonce is different from GetNonce(Address) result of the Signer.

| Improve this Doc View Source

Finalize()

Declaration
protected void Finalize()
| Improve this Doc View Source

GetEnumerator()

Declaration
public IEnumerator<Block<T>> GetEnumerator()
Returns
Type Description
IEnumerator<Block<T>>
| Improve this Doc View Source

GetNonce(Address)

Declaration
public long GetNonce(Address address)
Parameters
Type Name Description
Address address
Returns
Type Description
Int64
| Improve this Doc View Source

GetStates(IEnumerable<Address>, Nullable<HashDigest<SHA256>>)

Gets the state of the given addresses in the BlockChain<T> from offset.

Declaration
public AddressStateMap GetStates(IEnumerable<Address> addresses, HashDigest<SHA256>? offset = default(HashDigest<SHA256>? ))
Parameters
Type Name Description
IEnumerable<Address> addresses

The list of Addresses to get their states.

Nullable<HashDigest<SHA256>> offset

The HashDigest<T> of the block to start finding the state. It will be The tip of the BlockChain<T> if it is null.

Returns
Type Description
AddressStateMap

The AddressStateMap of given addresses.

| Improve this Doc View Source

MineBlock(Address)

Declaration
public Block<T> MineBlock(Address miner)
Parameters
Type Name Description
Address miner
Returns
Type Description
Block<T>
| Improve this Doc View Source

MineBlock(Address, DateTimeOffset)

Declaration
public Block<T> MineBlock(Address miner, DateTimeOffset currentTime)
Parameters
Type Name Description
Address miner
DateTimeOffset currentTime
Returns
Type Description
Block<T>
| Improve this Doc View Source

StageTransactions(ISet<Transaction<T>>)

Adds transactions to the pending list so that a next Block<T> to be mined contains these transactions.

Declaration
public void StageTransactions(ISet<Transaction<T>> transactions)
Parameters
Type Name Description
ISet<Transaction<T>> transactions

Transaction<T>s to add to the pending list.

| Improve this Doc View Source

UnstageTransactions(ISet<Transaction<T>>)

Removes transactions from the pending list.

Declaration
public void UnstageTransactions(ISet<Transaction<T>> transactions)
Parameters
Type Name Description
ISet<Transaction<T>> transactions

Transaction<T>s to remove from the pending list.

See Also
StageTransactions(ISet<Transaction<T>>)
| Improve this Doc View Source

Validate(IReadOnlyList<Block<T>>, DateTimeOffset)

Declaration
public void Validate(IReadOnlyList<Block<T>> blocks, DateTimeOffset currentTime)
Parameters
Type Name Description
IReadOnlyList<Block<T>> blocks
DateTimeOffset currentTime

Explicit Interface Implementations

| Improve this Doc View Source

IReadOnlyCollection<Block<T>>.Count

Declaration
int IReadOnlyCollection<Block<T>>.Count { get; }
Returns
Type Description
Int32
| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
IEnumerator

Implements

System.Collections.Generic.IReadOnlyList<T>
System.Collections.Generic.IReadOnlyCollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
  • Improve this Doc
  • View Source
Back to top Copyright © 2019 Planetarium
Generated by DocFX