Show / Hide Table of Contents

Class MerkleTrie

An ITrie implementation implemented Merkle Patricia Trie.

Inheritance
Object
MerkleTrie
Implements
ITrie
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.dll
Syntax
public class MerkleTrie : object, ITrie

Constructors

| Improve this Doc View Source

MerkleTrie(IKeyValueStore, HashDigest<SHA256>, Boolean)

An ITrie implementation.

Declaration
public MerkleTrie(IKeyValueStore keyValueStore, HashDigest<SHA256> rootHash, bool secure = false)
Parameters
Type Name Description
IKeyValueStore keyValueStore

The IKeyValueStore storage to store nodes.

HashDigest<SHA256> rootHash

The root Hash of MerkleTrie.

Boolean secure

Whether to use MerkleTrie in secure mode. If it is turned on, MerkleTrie internally stores hashed keys instead of bare keys. Keys will be hashed with SHA-256.

Fields

| Improve this Doc View Source

EmptyRootHash

Declaration
public static readonly HashDigest<SHA256> EmptyRootHash
Field Value
Type Description
HashDigest<SHA256>

Properties

| Improve this Doc View Source

Hash

The state root hash of the trie.

Declaration
public HashDigest<SHA256> Hash { get; }
Property Value
Type Description
HashDigest<SHA256>
| Improve this Doc View Source

Recorded

Whether the trie root is recorded in the store.

Declaration
public bool Recorded { get; }
Property Value
Type Description
Boolean
Remarks

Empty root is considered as recorded.

Methods

| Improve this Doc View Source

Commit()

Cleans up and stores the ITrie in storage.

Declaration
public ITrie Commit()
Returns
Type Description
ITrie

Returns new committed ITrie.

| Improve this Doc View Source

Get(IReadOnlyList<KeyBytes>)

Gets the values stored with keys in Set(in KeyBytes, IValue).

Declaration
public IReadOnlyList<IValue?> Get(IReadOnlyList<KeyBytes> keys)
Parameters
Type Name Description
IReadOnlyList<KeyBytes> keys

The keys used in Set(in KeyBytes, IValue) to store a value.

Returns
Type Description
IReadOnlyList<Nullable<IValue>>

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

| Improve this Doc View Source

Set(in KeyBytes, IValue)

Stores the value to the node corresponding to given key.

Declaration
public ITrie Set(in KeyBytes key, IValue value)
Parameters
Type Name Description
KeyBytes key

The unique key to associate with the value.

IValue value

The value to store.

Returns
Type Description
ITrie

Returns new updated ITrie.

Operators

| Improve this Doc View Source

Equality(MerkleTrie, MerkleTrie)

Declaration
public static bool operator ==(MerkleTrie left, MerkleTrie right)
Parameters
Type Name Description
MerkleTrie left
MerkleTrie right
Returns
Type Description
Boolean
| Improve this Doc View Source

Inequality(MerkleTrie, MerkleTrie)

Declaration
public static bool operator !=(MerkleTrie left, MerkleTrie right)
Parameters
Type Name Description
MerkleTrie left
MerkleTrie right
Returns
Type Description
Boolean

Implements

ITrie

Extension Methods

MerkleTrieExtensions.DifferentNodes(MerkleTrie, MerkleTrie)
MerkleTrieExtensions.ListAllStates(MerkleTrie)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium