Show / Hide Table of Contents

Class TrieStateStore

An IStateStore implementation. It stores states with MerkleTrie.

Inheritance
System.Object
TrieStateStore
Implements
IStateStore
IDisposable
Namespace: Libplanet.Store
Assembly: Libplanet.Store.dll
Syntax
public class TrieStateStore : object, IStateStore

Constructors

| Improve this Doc View Source

TrieStateStore(IKeyValueStore)

Creates a new TrieStateStore.

Declaration
public TrieStateStore(IKeyValueStore stateKeyValueStore)
Parameters
Type Name Description
IKeyValueStore stateKeyValueStore

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

Properties

| Improve this Doc View Source

StateKeyValueStore

An IStateStore implementation. It stores states with MerkleTrie.

Declaration
public IKeyValueStore StateKeyValueStore { get; }
Property Value
Type Description
IKeyValueStore

Methods

| Improve this Doc View Source

Commit(ITrie)

Commits given trie to storage. Returned ITrie must be identical to the one obtained from GetStateRoot(Nullable<HashDigest<SHA256>>) with resulting ITrie's Hash.

Declaration
public ITrie Commit(ITrie trie)
Parameters
Type Name Description
ITrie trie

The ITrie to commit.

Returns
Type Description
ITrie

The committed ITrie. The committed ITrie's Root is guaranteed to be either null or a HashNode.

Remarks

Given trie must have originated from the same instance (or with an instance with the same reference to an IKeyValueStore). Otherwise, this is not guaranteed to work properly.

See Also
GetStateRoot(System.Nullable<HashDigest<SHA256>>)
| Improve this Doc View Source

CopyStates(IImmutableSet<HashDigest<SHA256>>, TrieStateStore)

Copies states under state root hashes of given stateRootHashes to targetStateStore.

Under the hood, this not only copies states directly associated with stateRootHashes, but also automatically copies states that are not directly associated with stateRootHashes but associated with "subtries" with references stored in ITries of stateRootHashes.

Declaration
public void CopyStates(IImmutableSet<HashDigest<SHA256>> stateRootHashes, TrieStateStore targetStateStore)
Parameters
Type Name Description
IImmutableSet<HashDigest<SHA256>> stateRootHashes

The state root hashes of states to copy.

TrieStateStore targetStateStore

The target state store to copy state root hashes.

| Improve this Doc View Source

Dispose()

An IStateStore implementation. It stores states with MerkleTrie.

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

GetStateRoot(Nullable<HashDigest<SHA256>>)

Gets the state root trie of the stateRootHash from the state store.

Declaration
public ITrie GetStateRoot(HashDigest<SHA256>? stateRootHash)
Parameters
Type Name Description
System.Nullable<HashDigest<SHA256>> stateRootHash

The state root hash of the state root trie to get. If null is passed the empty state root trie is returned.

Returns
Type Description
ITrie

The state root trie of the stateRootHash. If null is passed the empty state root trie is returned.

Implements

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