Class StateStoreExtensions
Convenient extension methods for IStateStore.
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public static class StateStoreExtensions : object
Methods
| Improve this Doc View SourceCommit(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 |
Nullable<HashDigest<SHA256>> | previousStateRootHash | The state root hash on which
the |
IImmutableDictionary<String, IValue> | rawStatesDelta | The raw states delta to be recorded. |
Returns
Type | Description |
---|---|
ITrie | The new state root. |
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 |
|
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. |
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. |
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 |