Show / Hide Table of Contents

Namespace Libplanet.Store

Classes

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, and string.
    • Special types: Any type inherited from DataModel.
    • Collective types:
      • System.Collections.Immutable.ImmutableList<T> where T is a primitive type.
      • System.Collections.Immutable.ImmutableDictionary<TKey, TValue> where
        • TKey is one of ImmutableArray<byte>, Address, Guid, and string.
        • TValue is a primitive type.
  • Value types are not allowed to be declared as nullable, not even as a generic type parameter. That is, types such as bool?, Address?, and ImmutableList<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:

journaltrue (default) or false. Corresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s journal parameter.
index-cacheCorresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s indexCacheSize parameter. 50000 by default.
block-cacheCorresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s blockCacheSize parameter. 512 by default.
tx-cacheCorresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s txCacheSize parameter. 1024 by default.
flushtrue (default) or false. Corresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s flush parameter.
readonlytrue or false (default). Corresponds to DefaultStore(String, Boolean, Int32, Int32, Int32, Boolean, Boolean)'s readOnly parameter.
states-dirCorresponds to DefaultKeyValueStore(String)'s path parameter. It is relative to the URI path, and defaults to states.

HashNodeCache

A class used for internally caching hashed nodes of MerkleTries.

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.

In This Article
Back to top Copyright © 2018–2023 Planetarium