Show / Hide Table of Contents

Class MerkleTrie

An ITrie implementation implemented Merkle Patricia Trie.

Inheritance
Object
MerkleTrie
Implements
ITrie
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.dll
Syntax
public class MerkleTrie : 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. Hash(Byte[]) is used to hash them.

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

Declaration
public HashDigest<SHA256> Hash { get; }
Property Value
Type Description
HashDigest<SHA256>

Methods

| Improve this Doc View Source

Commit(Boolean)

Cleans up and stores the ITrie in storage.

Declaration
public ITrie Commit(bool rehearsal = false)
Parameters
Type Name Description
Boolean rehearsal

Whether to store nodes.

Returns
Type Description
ITrie

Returns new committed ITrie.

| Improve this Doc View Source

Set(Byte[], IValue)

Stores the value to the node corresponding to given key.

Declaration
public ITrie Set(byte[] key, IValue value)
Parameters
Type Name Description
Byte[] key

An index to look with TryGet(Byte[], out Nullable<IValue>) after.

IValue value

The value to store.

Returns
Type Description
ITrie

Returns new updated ITrie.

Exceptions
Type Condition
ArgumentNullException

Thrown when the given value is null.

| Improve this Doc View Source

TryGet(Byte[], out Nullable<IValue>)

Gets the value stored with key in Set(Byte[], IValue).

Declaration
public bool TryGet(byte[] key, out IValue? value)
Parameters
Type Name Description
Byte[] key

The key used in Set(Byte[], IValue) to store a value.

Nullable<IValue> value

The reference pointer to be set the value stored.

Returns
Type Description
Boolean

If there is a value corresponded to key, set value to it and return true. If not, set value to null and return false.

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