Show / Hide Table of Contents

Interface IBlockChainStates

A minimal interface to get states from a .

Note that implements this interface.

Namespace: Libplanet.Action.State
Assembly: Libplanet.Action.dll
Syntax
public interface IBlockChainStates

Methods

| Improve this Doc View Source

GetAccountState(Nullable<HashDigest<SHA256>>)

Returns the IAccountState in the 's state storage with hash.

Declaration
IAccountState GetAccountState(HashDigest<SHA256>? hash)
Parameters
Type Name Description
Nullable<HashDigest<SHA256>> hash

The state root hash for which to create an IAccountState.

Returns
Type Description
IAccountState

The IAccountState with hash as its state root hash.

Exceptions
Type Condition
ArgumentException

Thrown when no ITrie with hash as its state root hash is found.

See Also
IAccountState
| Improve this Doc View Source

GetAccountState(Nullable<BlockHash>)

Returns the IAccountState in the at offset.

Declaration
IAccountState GetAccountState(BlockHash? offset)
Parameters
Type Name Description
Nullable<BlockHash> offset

The BlockHash of the Block to create for which to create an IAccountState.

Returns
Type Description
IAccountState

The IAccountState at offset.

Exceptions
Type Condition
ArgumentException

Thrown when offset is not null and one of the following is true.

  • Corresponding Block is not found in the IStore.
  • Corresponding Block is found but its state root is not found in the IStateStore.
See Also
IAccountState
| Improve this Doc View Source

GetBalance(Address, Currency, Nullable<BlockHash>)

Gets address's balance for given currency in the at offset.

Declaration
FungibleAssetValue GetBalance(Address address, Currency currency, BlockHash? offset)
Parameters
Type Name Description
Address address

The owner Address to query.

Currency currency

The currency type to query.

Nullable<BlockHash> offset

The BlockHash of the Block to fetch the states from.

Returns
Type Description
FungibleAssetValue

The address's balance for currency at offset. If absent, returns 0 FungibleAssetValue for currency.

Exceptions
Type Condition
ArgumentException

Thrown when IAccount at offset cannot be created.

| Improve this Doc View Source

GetState(Address, Nullable<BlockHash>)

Gets a state associated to specified address.

Declaration
IValue GetState(Address address, BlockHash? offset)
Parameters
Type Name Description
Address address

The Address of the state to query.

Nullable<BlockHash> offset

The BlockHash of the Block to fetch the states from.

Returns
Type Description
Bencodex.Types.IValue

The state associated to specified address. An absent state is represented as null. The returned value must be the same as the single element when retrieved via GetStates(IReadOnlyList<Address>, Nullable<BlockHash>).

Remarks

For performance reasons, it is generally recommended to use GetStates(IReadOnlyList<Address>, Nullable<BlockHash>) with a batch of Addresses instead of iterating over this method.

Exceptions
Type Condition
ArgumentException

Thrown when offset is not null and one of the following is true.

  • Corresponding Block is not found in the IStore.
  • Corresponding Block is found but its state root is not found in the IStateStore.
| Improve this Doc View Source

GetStates(IReadOnlyList<Address>, Nullable<BlockHash>)

Gets multiple states associated to specified addresses.

Declaration
IReadOnlyList<IValue> GetStates(IReadOnlyList<Address> addresses, BlockHash? offset)
Parameters
Type Name Description
IReadOnlyList<Address> addresses

The Addresses of the states to query.

Nullable<BlockHash> offset

The BlockHash of the Block to fetch the states from.

Returns
Type Description
IReadOnlyList<Bencodex.Types.IValue>

The states associated to specified addresses. Associated values are ordered in the same way to the corresponding addresses. Absent states are represented as null. Hence, the returned IReadOnlyList<T> is guaranteeed to be of the same length as addresses with possible null values.

Exceptions
Type Condition
ArgumentException

Thrown when offset is not null and one of the following is true.

  • Corresponding Block is not found in the IStore.
  • Corresponding Block is found but its state root is not found in the IStateStore.
| Improve this Doc View Source

GetTotalSupply(Currency, Nullable<BlockHash>)

Gets the total supply of a currency in the at offset, and if not found, returns 0.

Declaration
FungibleAssetValue GetTotalSupply(Currency currency, BlockHash? offset)
Parameters
Type Name Description
Currency currency

The currency type to query.

Nullable<BlockHash> offset

The BlockHash of the Block to fetch the states from.

Returns
Type Description
FungibleAssetValue

The total supply value of currency at offset in FungibleAssetValue. If absent, returns 0 FungibleAssetValue for currency.

Exceptions
Type Condition
ArgumentException

Thrown when IAccount at offset cannot be created.

TotalSupplyNotTrackableException

Thrown when given currency's TotalSupplyTrackable is false.

See Also
GetAccountState(Nullable<BlockHash>)
| Improve this Doc View Source

GetValidatorSet(Nullable<BlockHash>)

Returns the validator set in the at offset.

Declaration
ValidatorSet GetValidatorSet(BlockHash? offset)
Parameters
Type Name Description
Nullable<BlockHash> offset

The BlockHash of the Block to fetch the states from.

Returns
Type Description
ValidatorSet

The validator set of type ValidatorSet at offset.

Exceptions
Type Condition
ArgumentException

Thrown when IAccount at offset cannot be created.

See Also
GetAccountState(Nullable<BlockHash>)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium