-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathFeatureDisableService.cs
More file actions
41 lines (35 loc) · 1.37 KB
/
FeatureDisableService.cs
File metadata and controls
41 lines (35 loc) · 1.37 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
36
37
38
39
40
41
using AElf.Kernel.Blockchain.Application;
using AElf.Kernel.FeatureDisable.Core;
using Volo.Abp.DependencyInjection;
namespace AElf.Kernel.FeatureDisable;
public class FeatureDisableService : IFeatureDisableService, ITransientDependency
{
private readonly IDisabledFeatureListProvider _disabledFeatureListProvider;
private readonly IBlockchainService _blockchainService;
public FeatureDisableService(IDisabledFeatureListProvider disabledFeatureListProvider,
IBlockchainService blockchainService)
{
_disabledFeatureListProvider = disabledFeatureListProvider;
_blockchainService = blockchainService;
}
public async Task<bool> IsFeatureDisabledAsync(params string[] featureNames)
{
var chain = await _blockchainService.GetChainAsync();
if (chain == null || chain.BestChainHeight <= 1)
{
// Which means chain hasn't been created yet or only genesis block exists.
return false;
}
var nameList = await _disabledFeatureListProvider.GetDisabledFeatureListAsync(new BlockIndex
{
BlockHash = chain.BestChainHash,
BlockHeight = chain.BestChainHeight
});
if (nameList.Length == 0)
{
return false;
}
var isDisabled = nameList.Select(n => n.Trim()).Intersect(featureNames).Any();
return isDisabled;
}
}