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 |
---|---|---|
IKey |
keyValueStore | The IKey |
Hash |
rootHash | The root Hash of
Merkle |
Boolean | secure | Whether to use Merkle |
Fields
| Improve this Doc View SourceEmptyRootHash
Declaration
public static readonly HashDigest<SHA256> EmptyRootHash
Field Value
Type | Description |
---|---|
Hash |
Properties
| Improve this Doc View SourceHash
The state root hash of the trie.
Declaration
public HashDigest<SHA256> Hash { get; }
Property Value
Type | Description |
---|---|
Hash |
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
| Improve this Doc View SourceGet(IReadOnlyList<KeyBytes>)
Gets the values stored with keys
in Set(in Key
Declaration
public IReadOnlyList<IValue?> Get(IReadOnlyList<KeyBytes> keys)
Parameters
Type | Name | Description |
---|---|---|
IRead |
keys | The keys used in Set(in Key |
Returns
Type | Description |
---|---|
IRead |
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 |
---|---|---|
Key |
key | The unique key to associate with the |
IValue | value | The value to store. |
Returns
Operators
| Improve this Doc View SourceEquality(MerkleTrie, MerkleTrie)
Declaration
public static bool operator ==(MerkleTrie left, MerkleTrie right)
Parameters
Type | Name | Description |
---|---|---|
Merkle |
left | |
Merkle |
right |
Returns
Type | Description |
---|---|
Boolean |
Inequality(MerkleTrie, MerkleTrie)
Declaration
public static bool operator !=(MerkleTrie left, MerkleTrie right)
Parameters
Type | Name | Description |
---|---|---|
Merkle |
left | |
Merkle |
right |
Returns
Type | Description |
---|---|
Boolean |