Show / Hide Table of Contents

Interface IBlockStatesStore

An interface to store block states and state references to them.

Inherited Members
IStateStore.SetStates<T>(Block<T>, IImmutableDictionary<String, IValue>)
IStateStore.GetState(String, Nullable<HashDigest<SHA256>>, Nullable<Guid>)
IStateStore.ContainsBlockStates(HashDigest<SHA256>)
IStateStore.ForkStates<T>(Guid, Guid, Block<T>)
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public interface IBlockStatesStore : IStateStore

Methods

| Improve this Doc View Source

ForkStateReferences<T>(Guid, Guid, Block<T>)

Forks state references, which are Hashes that have the state of the Addresses, from sourceChainId to destinationChainId.

This method copies state references from sourceChainId to destinationChainId and strips state references after branchPoint.

Declaration
void ForkStateReferences<T>(Guid sourceChainId, Guid destinationChainId, Block<T> branchPoint)
    where T : IAction, new()
Parameters
Type Name Description
Guid sourceChainId

The chain ID of state references to fork.

Guid destinationChainId

The new chain ID to have state references.

Block<T> branchPoint

The branch point Block<T> to fork.

Type Parameters
Name Description
T

An IAction class used with branchPoint.

Exceptions
Type Condition
ChainIdNotFoundException

Thrown when the given sourceChainId does not exist.

See Also
IterateStateReferences(Guid, String, Nullable<Int64>, Nullable<Int64>, Nullable<Int32>)
StoreStateReference(Guid, IImmutableSet<String>, HashDigest<SHA256>, Int64)
| Improve this Doc View Source

GetBlockStates(HashDigest<SHA256>)

Gets the states updated by actions in the inquired block.

Declaration
IImmutableDictionary<string, IValue> GetBlockStates(HashDigest<SHA256> blockHash)
Parameters
Type Name Description
HashDigest<SHA256> blockHash

Hash to query.

Returns
Type Description
IImmutableDictionary<String, IValue>

The states updated by actions in the inquired block. If actions definitely do not update any addresses it returns an empty map. If there is no record for the inquired block (because actions in it have never been evaluated yet) it returns null instead.

Remarks

It does not return all states built up from the genesis block nor delta, but only dirty states by actions the inquired block.

For example, if actions in the genesis block do a++; b++, /// and actions in the second block do b++; c++, this method /// for the second block returns b = 2; c = 1 (dirty), not a = 1; b = 2; c = 1 (all states) nor b = 1; c = 1 (delta).

See Also
SetBlockStates(HashDigest<SHA256>, IImmutableDictionary<String, IValue>)
| Improve this Doc View Source

IterateStateReferences(Guid, String, Nullable<Int64>, Nullable<Int64>, Nullable<Int32>)

Gets pairs of a state reference and a corresponding Index of the requested key in the specified chainId.

Declaration
IEnumerable<Tuple<HashDigest<SHA256>, long>> IterateStateReferences(Guid chainId, string key, long? highestIndex = null, long? lowestIndex = null, int? limit = null)
Parameters
Type Name Description
Guid chainId

The chain ID.

String key

The key to get state references.

Nullable<Int64> highestIndex

The highest index of state references to get. If it is null, it will be the highest index possible.

Nullable<Int64> lowestIndex

The lowest index of state references to get. If it is null, it will be the lowest index possible.

Nullable<Int32> limit

The maximum number of state references to get. If it is null, it does not limit the number of state references.

Returns
Type Description
IEnumerable<Tuple<HashDigest<SHA256>, Int64>>

Ordered pairs of a state reference and a corresponding Index. The highest index (i.e., the closest to the tip) goes first and the lowest index (i.e., the closest to the genesis) goes last.

See Also
StoreStateReference(Guid, IImmutableSet<String>, HashDigest<SHA256>, Int64)
| Improve this Doc View Source

ListAllStateReferences(Guid, Int64, Int64)

Lists all accounts, that have any states, in the given chainId and their state references.

Declaration
IImmutableDictionary<string, IImmutableList<HashDigest<SHA256>>> ListAllStateReferences(Guid chainId, long lowestIndex = null, long highestIndex = null)
Parameters
Type Name Description
Guid chainId

The chain ID to look up state references.

Int64 lowestIndex

Includes state references only made after the block this argument refers to.

Int64 highestIndex

Excludes state references made after the block this argument refers to.

Returns
Type Description
IImmutableDictionary<String, IImmutableList<HashDigest<SHA256>>>

A dictionary of account addresses to lists of their corresponding state references. Each list of state references is in ascending order, i.e., the block closest to the genesis goes first and the block closest to the tip goes last.

| Improve this Doc View Source

ListStateKeys(Guid)

Lists all keys that have ever had states.

Declaration
IEnumerable<string> ListStateKeys(Guid chainId)
Parameters
Type Name Description
Guid chainId

The ID of the chain to list state keys.

Returns
Type Description
IEnumerable<String>

All state keys in an arbitrary order. The order might be vary for each call.

| Improve this Doc View Source

LookupStateReference(Guid, String, Int64)

Looks up a state reference, which is a block's Hash that contains an action mutating the key's tate.

Declaration
Tuple<HashDigest<SHA256>, long> LookupStateReference(Guid chainId, string key, long lookupUntilBlockIndex)
Parameters
Type Name Description
Guid chainId

The chain ID to look up a state reference.

String key

The state key to look up.

Int64 lookupUntilBlockIndex

The index of the block to stop looking up.

Returns
Type Description
Tuple<HashDigest<SHA256>, Int64>

Returns a nullable tuple consisting of Hash and Index of the Block<T> with the state of the address.

See Also
IterateStateReferences(Guid, String, Nullable<Int64>, Nullable<Int64>, Nullable<Int32>)
| Improve this Doc View Source

PruneBlockStates<T>(Guid, Block<T>)

Prunes states in blockchain chainId with until specified block until.

Declaration
void PruneBlockStates<T>(Guid chainId, Block<T> until)
    where T : IAction, new()
Parameters
Type Name Description
Guid chainId

The chain ID to prune block states.

Block<T> until

The upper bound block to prune states.

Type Parameters
Name Description
T

An IAction class used with until.

| Improve this Doc View Source

SetBlockStates(HashDigest<SHA256>, IImmutableDictionary<String, IValue>)

Sets the states updated by actions in the specified block (i.e., blockHash).

Declaration
void SetBlockStates(HashDigest<SHA256> blockHash, IImmutableDictionary<string, IValue> states)
Parameters
Type Name Description
HashDigest<SHA256> blockHash

Hash to update states.

IImmutableDictionary<String, IValue> states

The states updated by actions in the specified block (i.e., blockHash).

See Also
GetBlockStates(HashDigest<SHA256>)
| Improve this Doc View Source

StoreStateReference(Guid, IImmutableSet<String>, HashDigest<SHA256>, Int64)

Marks the specified keys updated by any action in the specified block (i.e., blockHash).

Declaration
void StoreStateReference(Guid chainId, IImmutableSet<string> keys, HashDigest<SHA256> blockHash, long blockIndex)
Parameters
Type Name Description
Guid chainId

The ID of the chain to store a state reference.

IImmutableSet<String> keys

The keys updated by the block.

HashDigest<SHA256> blockHash

The Hash of the block which changes the keys' states.

Int64 blockIndex

The block index.

See Also
IterateStateReferences(Guid, String, Nullable<Int64>, Nullable<Int64>, Nullable<Int32>)
  • Improve this Doc
  • View Source
Back to top Copyright © 2019–2020 Planetarium