Show / Hide Table of Contents

Class TrieStateStore

An IStateStore implementation. It stores states with MerkleTrie.

Inheritance
Object
TrieStateStore
Implements
IStateStore
IDisposable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public class TrieStateStore : IStateStore, IDisposable

Constructors

| Improve this Doc View Source

TrieStateStore(IKeyValueStore, IKeyValueStore, Boolean)

Creates a new TrieStateStore.

Declaration
public TrieStateStore(IKeyValueStore stateKeyValueStore, IKeyValueStore stateHashKeyValueStore, bool secure = false)
Parameters
Type Name Description
IKeyValueStore stateKeyValueStore

The storage to store states. It used by MerkleTrie in internal.

IKeyValueStore stateHashKeyValueStore

The storage to store state hash corresponding to block hash.

Boolean secure

Whether to use MerkleTrie in secure mode. Libplanet.Store.Trie.MerkleTrie.#ctor(Libplanet.Store.Trie.IKeyValueStore,Libplanet.Store.Trie.Nodes.INode,System.Boolean).

Methods

| Improve this Doc View Source

ContainsBlockStates(HashDigest<SHA256>)

Checks if the states corresponded to the block derived from blockHash exist.

Declaration
public bool ContainsBlockStates(HashDigest<SHA256> blockHash)
Parameters
Type Name Description
HashDigest<SHA256> blockHash

The Hash of Block<T>.

Returns
Type Description
Boolean

Whether it contains the block states corresponded to blockHash.

| Improve this Doc View Source

Dispose()

Declaration
public void Dispose()
| Improve this Doc View Source

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

Copies metadata related to states from sourceChainId to destinationChainId, with branchpoint.

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

The Id of the chain which copies from.

Guid destinationChainId

The Id of the chain which copies to.

Block<T> branchpoint

The branchpoint to begin coping.

Type Parameters
Name Description
T

An IAction type. It should match to branchpoint's type parameter.

| Improve this Doc View Source

GetRootHash(HashDigest<SHA256>)

Gets the state hash corresponds to blockHash.

Declaration
public HashDigest<SHA256> GetRootHash(HashDigest<SHA256> blockHash)
Parameters
Type Name Description
HashDigest<SHA256> blockHash

The Hash to get state hash.

Returns
Type Description
HashDigest<SHA256>

If there is a state hash corresponds to blockHash, it will return the state hash. If not, it will return null.

Exceptions
Type Condition
KeyNotFoundException

If there are no root hashes that correspond to blockHash.

| Improve this Doc View Source

GetState(String, Nullable<HashDigest<SHA256>>, Nullable<Guid>)

Declaration
public IValue? GetState(string stateKey, HashDigest<SHA256>? blockHash = default(HashDigest<SHA256>? ), Guid? chainId = default(Guid? ))
Parameters
Type Name Description
String stateKey
Nullable<HashDigest<SHA256>> blockHash
Nullable<Guid> chainId
Returns
Type Description
Nullable<IValue>
| Improve this Doc View Source

PruneStates(ImmutableHashSet<HashDigest<SHA256>>)

Declaration
public void PruneStates(ImmutableHashSet<HashDigest<SHA256>> excludeBlockHashes)
Parameters
Type Name Description
ImmutableHashSet<HashDigest<SHA256>> excludeBlockHashes
| Improve this Doc View Source

SetStates<T>(Block<T>, IImmutableDictionary<String, IValue>)

Sets states mapped as relation Hash → states. It guarantees GetState(String, Nullable<HashDigest<SHA256>>, Nullable<Guid>) will return the same state if you passed same block unless it has overwritten.

Declaration
public void SetStates<T>(Block<T> block, IImmutableDictionary<string, IValue> states)
    where T : IAction, new()
Parameters
Type Name Description
Block<T> block

The Block<T> to set states.

IImmutableDictionary<String, IValue> states

The dictionary of state keys to states.

Type Parameters
Name Description
T

An IAction type. It should match to block's type parameter.

Implements

IStateStore
System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium