Show / Hide Table of Contents

Class StateStoreExtensions

Convenient extension methods for IStateStore.

Inheritance
Object
StateStoreExtensions
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public static class StateStoreExtensions : object

Methods

| Improve this Doc View Source

Commit(IStateStore, Nullable<HashDigest<SHA256>>, IImmutableDictionary<String, IValue>, Boolean)

Records rawStatesDelta which is based on the previous state root, and returns the new state root.

Declaration
public static ITrie Commit(this IStateStore stateStore, HashDigest<SHA256>? previousStateRootHash, IImmutableDictionary<string, IValue> rawStatesDelta, bool rehearsal = false)
Parameters
Type Name Description
IStateStore stateStore

The IStateStore to records the rawStatesDelta.

Nullable<HashDigest<SHA256>> previousStateRootHash

The state root hash on which the rawStatesDelta is based.

IImmutableDictionary<String, IValue> rawStatesDelta

The raw states delta to be recorded.

Boolean rehearsal

If turned on, the rawStatesDelta is not recorded to the stateStore, but only shadow trie root is returned. Turned off by default.

Returns
Type Description
ITrie

The new state root.

| Improve this Doc View Source

ContainsStateRoot(IStateStore, HashDigest<SHA256>)

Checks if the state root is recorded in the stateStore.

Declaration
public static bool ContainsStateRoot(this IStateStore stateStore, HashDigest<SHA256> stateRootHash)
Parameters
Type Name Description
IStateStore stateStore

The IStateStore to check if the state root is recorded in it.

HashDigest<SHA256> stateRootHash

The hash of the state root to check if it is recorded.

Returns
Type Description
Boolean

true if the state root exists in the stateStore; otherwise, false.

| Improve this Doc View Source

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

Gets the state of the rawStateKey from the stateRootHash.

Declaration
public static IValue? GetState(this IStateStore stateStore, string rawStateKey, HashDigest<SHA256>? stateRootHash)
Parameters
Type Name Description
IStateStore stateStore

The IStateStore to get the state.

String rawStateKey

The key of the state to get.

Nullable<HashDigest<SHA256>> stateRootHash

The state root hash to get the state.

Returns
Type Description
Nullable<IValue>

The state of the rawStateKey if any. If there is no such key, returns null.

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