Class MerkleTrie
An ITrie implementation implemented Merkle Patricia Trie.
Implements
Namespace: Libplanet.Store.Trie
Assembly: Libplanet.dll
Syntax
public class MerkleTrie : object, ITrie
Constructors
| Improve this Doc View SourceMerkleTrie(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 SourceEmptyRootHash
Declaration
public static readonly HashDigest<SHA256> EmptyRootHash
Field Value
Type | Description |
---|---|
HashDigest<SHA256> |
Properties
| Improve this Doc View SourceHash
The state root hash of the trie.
Declaration
public HashDigest<SHA256> Hash { get; }
Property Value
Type | Description |
---|---|
HashDigest<SHA256> |
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 SourceCommit()
Cleans up and stores the ITrie in storage.
Declaration
public ITrie Commit()
Returns
Type | Description |
---|---|
ITrie | Returns new committed ITrie. |
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 |
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 |
IValue | value | The value to store. |
Returns
Type | Description |
---|---|
ITrie | Returns new updated ITrie. |
Operators
| Improve this Doc View SourceEquality(MerkleTrie, MerkleTrie)
Declaration
public static bool operator ==(MerkleTrie left, MerkleTrie right)
Parameters
Type | Name | Description |
---|---|---|
MerkleTrie | left | |
MerkleTrie | right |
Returns
Type | Description |
---|---|
Boolean |
Inequality(MerkleTrie, MerkleTrie)
Declaration
public static bool operator !=(MerkleTrie left, MerkleTrie right)
Parameters
Type | Name | Description |
---|---|---|
MerkleTrie | left | |
MerkleTrie | right |
Returns
Type | Description |
---|---|
Boolean |