Class TrieStateStore
An IStateStore implementation. It stores states with MerkleTrie.
Inherited Members
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public class TrieStateStore : IStateStore, IDisposable
Constructors
| Improve this Doc View SourceTrieStateStore(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 SourceContainsBlockStates(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 |
Returns
Type | Description |
---|---|
Boolean | Whether it contains the block states corresponded to
|
Dispose()
Declaration
public void Dispose()
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
|
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 |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | If there are no root hashes that correspond to
|
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> |
PruneStates(ImmutableHashSet<HashDigest<SHA256>>)
Declaration
public void PruneStates(ImmutableHashSet<HashDigest<SHA256>> excludeBlockHashes)
Parameters
Type | Name | Description |
---|---|---|
ImmutableHashSet<HashDigest<SHA256>> | excludeBlockHashes |
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
|