Namespace Libplanet.Store
Classes
BaseIndex<TKey, TVal>
BaseStore
Common code for several IStore implementations.
BlockSet
DataModel
A class
representing an abstract data model that can be easily
encoded and decoded to and from a Bencodex.Types.Dictionary.
Inheriting this class and simply declaring properties allows an instance of the child class to encode its data into a Bencodex.Types.Dictionary where the encoded Bencodex.Types.Dictionary has the concrete class'es each property name as its key and the each corresponding property value as its value.
However, there are certain restrictions that apply when using this class
:
-
The complete list of allowed property types are as follows:
-
Primitive types:
bool
,int
,long
,BigInteger
,ImmutableArray<byte>
,Guid
,Address
, andstring
. - Special types: Any type inherited from DataModel.
-
Collective types:
-
ImmutableList<T> where
T
is a primitive type. -
ImmutableDictionary<TKey,TValue> where
-
TKey
is one ofImmutableArray<byte>
,Address
,Guid
, andstring
. -
TValue
is a primitive type.
-
-
ImmutableList<T> where
-
Primitive types:
-
Value types are not allowed to be declared as
nullable
, not even as a generic type parameter. That is, types such asbool?
,Address?
, andImmutableList<int?>
are not allowed. - Reference types are not allowed to be assigned null. This will result in an Exception when Encode() is called.
- Trying to assign null to any property or to a part of a collection will result in an Exception when DataModel(Dictionary) is called.
DefaultStore
The default built-in IStore implementation. This stores data in the file system or in memory. It also uses LiteDB for some complex indices.
DefaultStore and DefaultKeyValueStore-backed
TrieStateStore can be instantiated from a URI with default+file:
scheme
using LoadStore(Uri), e.g.:
default+file:///var/data/planet/
default+file:///c:/Users/john/AppData/Local/planet/
The following query string parameters are supported:
journal | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s journal
parameter. |
index-cache | Corresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s
indexCacheSize parameter. 50000 by default. |
block-cache | Corresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s
blockCacheSize parameter. 512 by default. |
tx-cache | Corresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s
txCacheSize parameter. 1024 by default. |
flush | true (default) or false. Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s flush
parameter. |
readonly | true or false (default). Corresponds to
DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s readOnly
parameter. |
states-dir | Corresponds to DefaultKeyValueStore(String)'s path
parameter. It is relative to the URI path, and defaults to states . |
MemoryStore
Volatile in-memory store.
It is useful for storing temporal small chains, e.g., fixtures for unit tests of game logic.
MemoryStore and MemoryKeyValueStore-backed
TrieStateStore can be instantiated from a URI with memory:
scheme
using LoadStore(Uri), e.g.:
memory:
StoreExtensions
Convenient extension methods for IStore.
StoreLoaderAttribute
Registers a static method as a store loader. The method must comply with StoreLoader delegate.
TrieStateStore
An IStateStore implementation. It stores states with MerkleTrie.
Structs
BlockDigest
Class that store uses to save blocks. This contains: BlockHeader, and list of TxIds.
Interfaces
IStateStore
An interface to store states.
IStore
Delegates
StoreLoader
A function that parses a URI and returns a pair of IStore and IStateStore.