-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathBlockPruningAElfModule.cs
More file actions
35 lines (30 loc) · 1.31 KB
/
Copy pathBlockPruningAElfModule.cs
File metadata and controls
35 lines (30 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using AElf.Modularity;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace AElf.Kernel.BlockPruning;
[DependsOn(
typeof(CoreKernelAElfModule)
)]
public class BlockPruningAElfModule : AElfModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<BlockPruningOptions>(configuration.GetSection("BlockPruning"));
context.Services.PostConfigure<BlockPruningOptions>(options =>
{
options.RetainDistance = Math.Max(options.RetainDistance, BlockPruningConstants.MinRetainDistance);
options.BatchSize = Math.Clamp(options.BatchSize, 1, BlockPruningConstants.MaxBatchSize);
options.PruneThreshold = Math.Max(options.PruneThreshold, 0);
options.BatchDelayMilliseconds = Math.Max(options.BatchDelayMilliseconds, 0);
});
context.Services.AddStoreKeyPrefixProvide<BlockPruningInfo>("bp");
}
public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
{
var taskQueueManager = context.ServiceProvider.GetRequiredService<ITaskQueueManager>();
taskQueueManager.CreateQueue(BlockPruningConstants.BlockPruningQueueName);
}
}