diff --git a/Lib9c b/Lib9c index fe86a78e2..228977705 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit fe86a78e29d7d15486779b133bea21ba0ec63f30 +Subproject commit 228977705598b58e9c589cfcaf4169faaf3a9294 diff --git a/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs index 7bb3fa3e0..08d7a2759 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs @@ -46,7 +46,7 @@ public void Balance(StoreType storeType) var stateKeyValueStore = new RocksDBKeyValueStore(statesPath); var stateStore = new TrieStateStore(stateKeyValueStore); IStagePolicy stagePolicy = new VolatileStagePolicy(); - IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy(); + IBlockPolicy blockPolicy = new BlockPolicySource().GetPolicy(); ActionEvaluator actionEvaluator = new ActionEvaluator( _ => blockPolicy.BlockAction, new BlockChainStates(store, stateStore), diff --git a/NineChronicles.Headless.Executable.Tests/Commands/ChainCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/ChainCommandTest.cs index 17f04ca9a..dc21068eb 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/ChainCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/ChainCommandTest.cs @@ -90,7 +90,7 @@ public void Inspect(StoreType storeType) IStore store = storeType.CreateStore(_storePath); IStateStore stateStore = new TrieStateStore(new RocksDBKeyValueStore(Path.Combine(_storePath, "states"))); IStagePolicy stagePolicy = new VolatileStagePolicy(); - IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetTestPolicy(); + IBlockPolicy blockPolicy = new BlockPolicySource().GetTestPolicy(); ActionEvaluator actionEvaluator = new ActionEvaluator( _ => blockPolicy.BlockAction, new BlockChainStates(store, stateStore), @@ -151,7 +151,7 @@ public void Truncate(StoreType storeType) IStore store = storeType.CreateStore(_storePath); IStateStore stateStore = new TrieStateStore(new RocksDBKeyValueStore(Path.Combine(_storePath, "states"))); IStagePolicy stagePolicy = new VolatileStagePolicy(); - IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetTestPolicy(); + IBlockPolicy blockPolicy = new BlockPolicySource().GetTestPolicy(); ActionEvaluator actionEvaluator = new ActionEvaluator( _ => blockPolicy.BlockAction, new BlockChainStates(store, stateStore), @@ -230,7 +230,7 @@ public void PruneState(StoreType storeType) var stateKeyValueStore = new RocksDBKeyValueStore(statesPath); var stateStore = new TrieStateStore(stateKeyValueStore); IStagePolicy stagePolicy = new VolatileStagePolicy(); - IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy(); + IBlockPolicy blockPolicy = new BlockPolicySource().GetPolicy(); ActionEvaluator actionEvaluator = new ActionEvaluator( _ => blockPolicy.BlockAction, new BlockChainStates(store, stateStore), @@ -272,7 +272,7 @@ public void Snapshot(StoreType storeType) var stateKeyValueStore = new RocksDBKeyValueStore(statesPath); var stateStore = new TrieStateStore(stateKeyValueStore); IStagePolicy stagePolicy = new VolatileStagePolicy(); - IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy(); + IBlockPolicy blockPolicy = new BlockPolicySource().GetPolicy(); ActionEvaluator actionEvaluator = new ActionEvaluator( _ => blockPolicy.BlockAction, new BlockChainStates(store, stateStore), diff --git a/NineChronicles.Headless.Executable/Commands/ChainCommand.cs b/NineChronicles.Headless.Executable/Commands/ChainCommand.cs index 817fc859e..22ebe8425 100644 --- a/NineChronicles.Headless.Executable/Commands/ChainCommand.cs +++ b/NineChronicles.Headless.Executable/Commands/ChainCommand.cs @@ -114,7 +114,7 @@ public void Inspect( } IStagePolicy stagePolicy = new VolatileStagePolicy(); - IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy(); + IBlockPolicy blockPolicy = new BlockPolicySource().GetPolicy(); IStore store = storeType.CreateStore(storePath); var stateStore = new TrieStateStore(new DefaultKeyValueStore(null)); if (!(store.GetCanonicalChainId() is { } chainId)) diff --git a/NineChronicles.Headless.Executable/Commands/ReplayCommand.cs b/NineChronicles.Headless.Executable/Commands/ReplayCommand.cs index 19ebea278..9fb831a5a 100644 --- a/NineChronicles.Headless.Executable/Commands/ReplayCommand.cs +++ b/NineChronicles.Headless.Executable/Commands/ReplayCommand.cs @@ -475,7 +475,7 @@ private static (FileStream? fs, StreamWriter? sw) GetOutputFileStream( var genesisBlock = store.GetBlock(genesisBlockHash); // Make BlockChain and blocks. - var policy = new BlockPolicySource(Logger.None).GetPolicy(); + var policy = new BlockPolicySource().GetPolicy(); var stagePolicy = new VolatileStagePolicy(); var stateKeyValueStore = new RocksDBKeyValueStore(Path.Combine(storePath, "states")); var stateStore = new TrieStateStore(stateKeyValueStore); @@ -525,7 +525,7 @@ private Transaction LoadTx(string txPath) private ActionEvaluator GetActionEvaluator(BlockChain blockChain) { - var policy = new BlockPolicySource(Logger.None).GetPolicy(); + var policy = new BlockPolicySource().GetPolicy(); IActionLoader actionLoader = new NCActionLoader(); return new ActionEvaluator( _ => policy.BlockAction, diff --git a/NineChronicles.Headless/NineChroniclesNodeService.cs b/NineChronicles.Headless/NineChroniclesNodeService.cs index 155068c0e..9e075af5b 100644 --- a/NineChronicles.Headless/NineChroniclesNodeService.cs +++ b/NineChronicles.Headless/NineChroniclesNodeService.cs @@ -84,11 +84,10 @@ public NineChroniclesNodeService( Properties = properties; LogEventLevel logLevel = LogEventLevel.Debug; - var blockPolicySource = new BlockPolicySource(Log.Logger, logLevel); IStagePolicy stagePolicy = new NCStagePolicy(txLifeTime, txQuotaPerSigner); - BlockRenderer = blockPolicySource.BlockRenderer; - ActionRenderer = blockPolicySource.ActionRenderer; + BlockRenderer = new BlockRenderer(); + ActionRenderer = new ActionRenderer(); ExceptionRenderer = new ExceptionRenderer(); NodeStatusRenderer = new NodeStatusRenderer(); var renderers = new List(); @@ -101,12 +100,12 @@ public NineChroniclesNodeService( if (Properties.Render) { - renderers.Add(blockPolicySource.BlockRenderer); - renderers.Add(blockPolicySource.LoggedActionRenderer); + renderers.Add(BlockRenderer); + renderers.Add(new LoggedActionRenderer(ActionRenderer, Log.Logger, logLevel)); } else if (Properties.LogActionRenders) { - renderers.Add(blockPolicySource.BlockRenderer); + renderers.Add(BlockRenderer); // The following "nullRenderer" does nothing. It's just for filling // the LoggedActionRenderer() constructor's parameter: IActionRenderer nullRenderer = new AnonymousActionRenderer(); @@ -120,7 +119,7 @@ public NineChroniclesNodeService( } else { - renderers.Add(blockPolicySource.LoggedBlockRenderer); + renderers.Add(new LoggedRenderer(BlockRenderer, Log.Logger, logLevel)); } if (strictRendering) @@ -242,7 +241,7 @@ StandaloneContext context internal static IBlockPolicy GetBlockPolicy(NetworkType networkType, IActionLoader actionLoader) { - var source = new BlockPolicySource(Log.Logger, LogEventLevel.Debug, actionLoader); + var source = new BlockPolicySource(actionLoader); return networkType switch { NetworkType.Main => source.GetPolicy(), @@ -255,7 +254,7 @@ internal static IBlockPolicy GetBlockPolicy(NetworkType networkType, IActionLoad } internal static IBlockPolicy GetTestBlockPolicy() => - new BlockPolicySource(Log.Logger, LogEventLevel.Debug).GetTestPolicy(); + new BlockPolicySource().GetTestPolicy(); public Task CheckPeer(string addr) => NodeService?.CheckPeer(addr) ?? throw new InvalidOperationException();