Skip to content

Commit

Permalink
Revert renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Sep 25, 2023
1 parent 08e7ae4 commit 9aabae1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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().GetPolicy();
IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy();
ActionEvaluator actionEvaluator = new ActionEvaluator(
_ => blockPolicy.BlockAction,
new BlockChainStates(store, stateStore),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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().GetTestPolicy();
IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetTestPolicy();
ActionEvaluator actionEvaluator = new ActionEvaluator(
_ => blockPolicy.BlockAction,
new BlockChainStates(store, stateStore),
Expand Down Expand Up @@ -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().GetTestPolicy();
IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetTestPolicy();
ActionEvaluator actionEvaluator = new ActionEvaluator(
_ => blockPolicy.BlockAction,
new BlockChainStates(store, stateStore),
Expand Down Expand Up @@ -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().GetPolicy();
IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy();
ActionEvaluator actionEvaluator = new ActionEvaluator(
_ => blockPolicy.BlockAction,
new BlockChainStates(store, stateStore),
Expand Down Expand Up @@ -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().GetPolicy();
IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy();
ActionEvaluator actionEvaluator = new ActionEvaluator(
_ => blockPolicy.BlockAction,
new BlockChainStates(store, stateStore),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void Inspect(
}

IStagePolicy stagePolicy = new VolatileStagePolicy();
IBlockPolicy blockPolicy = new BlockPolicySource().GetPolicy();
IBlockPolicy blockPolicy = new BlockPolicySource(Logger.None).GetPolicy();
IStore store = storeType.CreateStore(storePath);
var stateStore = new TrieStateStore(new DefaultKeyValueStore(null));
if (!(store.GetCanonicalChainId() is { } chainId))
Expand Down
4 changes: 2 additions & 2 deletions NineChronicles.Headless.Executable/Commands/ReplayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ private static (FileStream? fs, StreamWriter? sw) GetOutputFileStream(
var genesisBlock = store.GetBlock(genesisBlockHash);

// Make BlockChain and blocks.
var policy = new BlockPolicySource().GetPolicy();
var policy = new BlockPolicySource(Logger.None).GetPolicy();
var stagePolicy = new VolatileStagePolicy();
var stateKeyValueStore = new RocksDBKeyValueStore(Path.Combine(storePath, "states"));
var stateStore = new TrieStateStore(stateKeyValueStore);
Expand Down Expand Up @@ -525,7 +525,7 @@ private Transaction LoadTx(string txPath)

private ActionEvaluator GetActionEvaluator(BlockChain blockChain)
{
var policy = new BlockPolicySource().GetPolicy();
var policy = new BlockPolicySource(Logger.None).GetPolicy();
IActionLoader actionLoader = new NCActionLoader();
return new ActionEvaluator(
_ => policy.BlockAction,
Expand Down
17 changes: 9 additions & 8 deletions NineChronicles.Headless/NineChroniclesNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ public NineChroniclesNodeService(
Properties = properties;

LogEventLevel logLevel = LogEventLevel.Debug;
var blockPolicySource = new BlockPolicySource(Log.Logger, logLevel);
IStagePolicy stagePolicy = new NCStagePolicy(txLifeTime, txQuotaPerSigner);

BlockRenderer = new BlockRenderer();
ActionRenderer = new ActionRenderer();
BlockRenderer = blockPolicySource.BlockRenderer;
ActionRenderer = blockPolicySource.ActionRenderer;
ExceptionRenderer = new ExceptionRenderer();
NodeStatusRenderer = new NodeStatusRenderer();
var renderers = new List<IRenderer>();
Expand All @@ -100,12 +101,12 @@ public NineChroniclesNodeService(

if (Properties.Render)
{
renderers.Add(BlockRenderer);
renderers.Add(new LoggedActionRenderer(ActionRenderer, Log.Logger, logLevel));
renderers.Add(blockPolicySource.BlockRenderer);
renderers.Add(blockPolicySource.LoggedActionRenderer);
}
else if (Properties.LogActionRenders)
{
renderers.Add(BlockRenderer);
renderers.Add(blockPolicySource.BlockRenderer);
// The following "nullRenderer" does nothing. It's just for filling
// the LoggedActionRenderer<T>() constructor's parameter:
IActionRenderer nullRenderer = new AnonymousActionRenderer();
Expand All @@ -119,7 +120,7 @@ public NineChroniclesNodeService(
}
else
{
renderers.Add(new LoggedRenderer(BlockRenderer, Log.Logger, logLevel));
renderers.Add(blockPolicySource.LoggedBlockRenderer);
}

if (strictRendering)
Expand Down Expand Up @@ -241,7 +242,7 @@ StandaloneContext context

internal static IBlockPolicy GetBlockPolicy(NetworkType networkType, IActionLoader actionLoader)
{
var source = new BlockPolicySource(actionLoader);
var source = new BlockPolicySource(Log.Logger, LogEventLevel.Debug, actionLoader);
return networkType switch
{
NetworkType.Main => source.GetPolicy(),
Expand All @@ -254,7 +255,7 @@ internal static IBlockPolicy GetBlockPolicy(NetworkType networkType, IActionLoad
}

internal static IBlockPolicy GetTestBlockPolicy() =>
new BlockPolicySource().GetTestPolicy();
new BlockPolicySource(Log.Logger, LogEventLevel.Debug).GetTestPolicy();

public Task<bool> CheckPeer(string addr) => NodeService?.CheckPeer(addr) ?? throw new InvalidOperationException();

Expand Down

0 comments on commit 9aabae1

Please sign in to comment.