From addfc623b6a9afb02295021e422a834c00d8b15e Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Mon, 25 Sep 2023 13:28:36 +0900 Subject: [PATCH] Removed ReducedStore --- .../Hosting/LibplanetNodeService.cs | 9 +- Libplanet.Headless/ReducedStore.cs | 150 ------------------ 2 files changed, 2 insertions(+), 157 deletions(-) delete mode 100644 Libplanet.Headless/ReducedStore.cs diff --git a/Libplanet.Headless/Hosting/LibplanetNodeService.cs b/Libplanet.Headless/Hosting/LibplanetNodeService.cs index 76ee633c6..25b10b962 100644 --- a/Libplanet.Headless/Hosting/LibplanetNodeService.cs +++ b/Libplanet.Headless/Hosting/LibplanetNodeService.cs @@ -98,8 +98,7 @@ public LibplanetNodeService( (Store, StateStore) = LoadStore( Properties.StorePath, Properties.StoreType, - Properties.StoreStatesCacheSize, - Properties.NoReduceStore); + Properties.StoreStatesCacheSize); var chainIds = Store.ListChainIds().ToList(); Log.Debug($"Number of chain ids: {chainIds.Count()}"); @@ -303,7 +302,7 @@ public override async Task StopAsync(CancellationToken cancellationToken) } } - protected (IStore, IStateStore) LoadStore(string path, string type, int statesCacheSize, bool noReduceStore = false) + protected (IStore, IStateStore) LoadStore(string path, string type, int statesCacheSize) { IStore store = null; if (type == "rocksdb") @@ -344,10 +343,6 @@ public override async Task StopAsync(CancellationToken cancellationToken) } store ??= new DefaultStore(path, flush: false); - if (!noReduceStore) - { - store = new ReducedStore(store); - } IKeyValueStore stateKeyValueStore = new RocksDBKeyValueStore(Path.Combine(path, "states")); IStateStore stateStore = new TrieStateStore(stateKeyValueStore); diff --git a/Libplanet.Headless/ReducedStore.cs b/Libplanet.Headless/ReducedStore.cs deleted file mode 100644 index 851fb6347..000000000 --- a/Libplanet.Headless/ReducedStore.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Collections.Generic; -using Libplanet.Crypto; -using Libplanet.Store; -using Libplanet.Types.Blocks; -using Libplanet.Types.Tx; - -namespace Libplanet.Headless -{ - /// - /// A decorator that reduce space consumption by omitting input calls which - /// are unused by Nine Chronicles. - /// Calls on this will be forwarded to its , except for: - /// - /// - /// - /// - public sealed class ReducedStore : IStore - { - public ReducedStore(IStore internalStore) - { - InternalStore = internalStore; - } - - public IStore InternalStore { get; } - - public long AppendIndex(Guid chainId, BlockHash hash) => - InternalStore.AppendIndex(chainId, hash); - - public bool ContainsBlock(BlockHash blockHash) => - InternalStore.ContainsBlock(blockHash); - - public bool ContainsTransaction(TxId txId) => - InternalStore.ContainsTransaction(txId); - - public long CountBlocks() => - InternalStore.CountBlocks(); - - public long CountIndex(Guid chainId) => - InternalStore.CountIndex(chainId); - - public bool DeleteBlock(BlockHash blockHash) => - InternalStore.DeleteBlock(blockHash); - - public void DeleteChainId(Guid chainId) => - InternalStore.DeleteChainId(chainId); - - public void ForkBlockIndexes( - Guid sourceChainId, - Guid destinationChainId, - BlockHash branchpoint - ) => - InternalStore.ForkBlockIndexes(sourceChainId, destinationChainId, branchpoint); - - public void ForkTxNonces(Guid sourceChainId, Guid destinationChainId) => - InternalStore.ForkTxNonces(sourceChainId, destinationChainId); - - public Block GetBlock(BlockHash blockHash) - => InternalStore.GetBlock(blockHash); - - public BlockDigest? GetBlockDigest(BlockHash blockHash) => - InternalStore.GetBlockDigest(blockHash); - - public long? GetBlockIndex(BlockHash blockHash) => - InternalStore.GetBlockIndex(blockHash); - - public Guid? GetCanonicalChainId() => - InternalStore.GetCanonicalChainId(); - - public Transaction GetTransaction(TxId txid) => - InternalStore.GetTransaction(txid); - - public TxExecution GetTxExecution(BlockHash blockHash, TxId txid) => - InternalStore.GetTxExecution(blockHash, txid); - - public long GetTxNonce(Guid chainId, Address address) => - InternalStore.GetTxNonce(chainId, address); - - public void IncreaseTxNonce(Guid chainId, Address signer, long delta = 1) => - InternalStore.IncreaseTxNonce(chainId, signer, delta); - - public BlockHash? IndexBlockHash(Guid chainId, long index) => - InternalStore.IndexBlockHash(chainId, index); - - public IEnumerable IterateBlockHashes() => - InternalStore.IterateBlockHashes(); - - public IEnumerable IterateIndexes( - Guid chainId, - int offset = 0, - int? limit = null - ) => - InternalStore.IterateIndexes(chainId, offset, limit); - - public IEnumerable ListChainIds() => - InternalStore.ListChainIds(); - - public IEnumerable> ListTxNonces(Guid chainId) => - InternalStore.ListTxNonces(chainId); - - public void PutBlock(Block block) => - InternalStore.PutBlock(block); - - public void PutTransaction(Transaction tx) => - InternalStore.PutTransaction(tx); - - public void PutTxExecution(TxExecution txExecution) - { - InternalStore.PutTxExecution(txExecution); - } - - public void SetCanonicalChainId(Guid chainId) => - InternalStore.SetCanonicalChainId(chainId); - - public void PutTxIdBlockHashIndex(TxId txId, BlockHash blockHash) => - InternalStore.PutTxIdBlockHashIndex(txId, blockHash); - - public BlockHash? GetFirstTxIdBlockHashIndex(TxId txId) => - InternalStore.GetFirstTxIdBlockHashIndex(txId); - - public IEnumerable IterateTxIdBlockHashIndex(TxId txId) => - InternalStore.IterateTxIdBlockHashIndex(txId); - - public void DeleteTxIdBlockHashIndex(TxId txId, BlockHash blockHash) => - InternalStore.DeleteTxIdBlockHashIndex(txId, blockHash); - - public void PruneOutdatedChains(bool noopWithoutCanon = false) => - InternalStore.PruneOutdatedChains(noopWithoutCanon); - - public BlockCommit GetChainBlockCommit(Guid chainId) => - InternalStore.GetChainBlockCommit(chainId); - - public void PutChainBlockCommit(Guid chainId, BlockCommit blockCommit) => - InternalStore.PutChainBlockCommit(chainId, blockCommit); - - public BlockCommit GetBlockCommit(BlockHash blockHash) => - InternalStore.GetBlockCommit(blockHash); - - public void PutBlockCommit(BlockCommit blockCommit) => - InternalStore.PutBlockCommit(blockCommit); - - public void DeleteBlockCommit(BlockHash blockHash) => - InternalStore.DeleteBlockCommit(blockHash); - - public IEnumerable GetBlockCommitHashes() => - InternalStore.GetBlockCommitHashes(); - - public void Dispose() => InternalStore.Dispose(); - } -}