Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Nov 15, 2023
1 parent 36edcf8 commit 2cb9598
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
20 changes: 8 additions & 12 deletions Libplanet.Extensions.Cocona/Commands/MptCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ public void Diff(
kvStoreUri = ConvertKVStoreUri(kvStoreUri, toolConfiguration);
otherKvStoreUri = ConvertKVStoreUri(otherKvStoreUri, toolConfiguration);

IKeyValueStore keyValueStore = LoadKVStoreFromURI(kvStoreUri);
IKeyValueStore otherKeyValueStore = LoadKVStoreFromURI(otherKvStoreUri);
var trie = new MerkleTrie(
keyValueStore,
HashDigest<SHA256>.FromString(stateRootHashHex));
var otherTrie = new MerkleTrie(
otherKeyValueStore,
HashDigest<SHA256>.FromString(otherStateRootHashHex));
IStateStore stateStore = new TrieStateStore(LoadKVStoreFromURI(kvStoreUri));
IStateStore otherStateStore = new TrieStateStore(LoadKVStoreFromURI(otherKvStoreUri));
var trie =
stateStore.GetStateRoot(HashDigest<SHA256>.FromString(stateRootHashHex));
var otherTrie =
otherStateStore.GetStateRoot(HashDigest<SHA256>.FromString(otherStateRootHashHex));

var codec = new Codec();
HashDigest<SHA256> originRootHash = trie.Hash;
Expand Down Expand Up @@ -113,10 +111,8 @@ public void Export(
ToolConfiguration toolConfiguration = configurationService.Load();
kvStoreUri = ConvertKVStoreUri(kvStoreUri, toolConfiguration);

IKeyValueStore keyValueStore = LoadKVStoreFromURI(kvStoreUri);
var trie = new MerkleTrie(
keyValueStore,
HashDigest<SHA256>.FromString(stateRootHashHex));
IStateStore stateStore = new TrieStateStore(LoadKVStoreFromURI(kvStoreUri));
var trie = stateStore.GetStateRoot(HashDigest<SHA256>.FromString(stateRootHashHex));
var codec = new Codec();

// This assumes the original key was encoded from a sensible string.
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Store/HashNodeCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HashNodeCache
private int _hits;
private object _reportLock;

public HashNodeCache()
internal HashNodeCache()
{
_cache = new LruCache<HashDigest<SHA256>, IValue>(_cahceSize);

Check warning on line 25 in Libplanet.Store/HashNodeCache.cs

View workflow job for this annotation

GitHub Actions / typos

"cahce" should be "cache".
_stopwatch = new Stopwatch();
Expand Down
10 changes: 6 additions & 4 deletions Libplanet.Store/Trie/MerkleTrie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ static MerkleTrie()
/// nodes.</param>
/// <param name="rootHash">The root <see cref="ITrie.Hash"/> of
/// <see cref="MerkleTrie"/>.</param>
/// <param name="cache">The <see cref="HashNodeCache"/> to use as a cache.</param>
/// <param name="cache">The <see cref="HashNodeCache"/> to use as cache.</param>
public MerkleTrie(
IKeyValueStore keyValueStore,
HashDigest<SHA256> rootHash,
HashNodeCache? cache = null)
: this(keyValueStore, new HashNode(rootHash))
: this(keyValueStore, new HashNode(rootHash), cache)
{
}

Expand All @@ -54,9 +54,11 @@ public MerkleTrie(
/// nodes.</param>
/// <param name="root">The root node of <see cref="MerkleTrie"/>. If it is
/// <see langword="null"/>, it will be treated like empty trie.</param>
/// <param name="cache">The <see cref="HashNodeCache"/> to use as a cache.</param>
/// <param name="cache">The <see cref="HashNodeCache"/> to use as cache.</param>
public MerkleTrie(
IKeyValueStore keyValueStore, INode? root = null, HashNodeCache? cache = null)
IKeyValueStore keyValueStore,
INode? root = null,
HashNodeCache? cache = null)
{
// FIXME: It might be a good idea to have something like IReadOnlyKeyValueStore.
KeyValueStore = keyValueStore;
Expand Down

0 comments on commit 2cb9598

Please sign in to comment.