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>)

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)
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.

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

DecodeKey(in KeyBytes)

Decodes internal keyBytes into a raw state key string.

Declaration
public static string DecodeKey(in KeyBytes keyBytes)
Parameters
Type Name Description
KeyBytes keyBytes

The key bytes to decode.

Returns
Type Description
String

A decoded raw state key string.

| Improve this Doc View Source

EncodeKey(String)

Encodes a raw state key string to internal bytes representation.

Declaration
public static KeyBytes EncodeKey(string key)
Parameters
Type Name Description
String key

The raw state key to encode.

Returns
Type Description
KeyBytes

An encoded key bytes.

| Improve this Doc View Source

GetStates(IStateStore, Nullable<HashDigest<SHA256>>, IReadOnlyList<String>)

Gets multiple states at once.

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

The IStateStore to get states.

Nullable<HashDigest<SHA256>> stateRootHash

The root hash of the state trie to look up states from.

IReadOnlyList<String> rawStateKeys

State keys to get.

Returns
Type Description
IReadOnlyList<Nullable<IValue>>

The state values associated to the specified rawStateKeys. The associated values are ordered in the same way to the corresponding rawStateKeys. Absent values are represented as null.

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