diff --git a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs index fec97aae90..8f156580ec 100644 --- a/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs +++ b/src/AElf.Blockchains.BasicBaseChain/GenesisSmartContractDtoProviderBase.cs @@ -12,10 +12,10 @@ namespace AElf.Blockchains.BasicBaseChain public abstract class GenesisSmartContractDtoProviderBase : IGenesisSmartContractDtoProvider { protected readonly IContractDeploymentListProvider ContractDeploymentListProvider; - protected readonly IServiceContainer ContractInitializationProviders; + protected readonly IEnumerable ContractInitializationProviders; protected GenesisSmartContractDtoProviderBase(IContractDeploymentListProvider contractDeploymentListProvider, - IServiceContainer contractInitializationProviders) + IEnumerable contractInitializationProviders) { ContractDeploymentListProvider = contractDeploymentListProvider; ContractInitializationProviders = contractInitializationProviders; diff --git a/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs b/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs index e1d4a87e6a..c163eb025f 100644 --- a/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs +++ b/src/AElf.Blockchains.MainChain/MainChainGenesisSmartContractDtoProvider.cs @@ -15,7 +15,7 @@ public class MainChainGenesisSmartContractDtoProvider : GenesisSmartContractDtoP private readonly ContractOptions _contractOptions; public MainChainGenesisSmartContractDtoProvider(IContractDeploymentListProvider contractDeploymentListProvider, - IServiceContainer contractInitializationProviders, + IEnumerable contractInitializationProviders, IOptionsSnapshot contractOptions) : base(contractDeploymentListProvider, contractInitializationProviders) { diff --git a/src/AElf.Blockchains.SideChain/SideChainGenesisSmartContractDtoProvider.cs b/src/AElf.Blockchains.SideChain/SideChainGenesisSmartContractDtoProvider.cs index 758823eb8f..82845100db 100644 --- a/src/AElf.Blockchains.SideChain/SideChainGenesisSmartContractDtoProvider.cs +++ b/src/AElf.Blockchains.SideChain/SideChainGenesisSmartContractDtoProvider.cs @@ -29,7 +29,7 @@ public class SideChainGenesisSmartContractDtoProvider : GenesisSmartContractDtoP public SideChainGenesisSmartContractDtoProvider( ISideChainInitializationDataProvider sideChainInitializationDataProvider, IContractDeploymentListProvider contractDeploymentListProvider, - IServiceContainer contractInitializationProviders, + IEnumerable contractInitializationProviders, IOptionsSnapshot contractOptions) :base(contractDeploymentListProvider, contractInitializationProviders) { diff --git a/src/AElf.Cluster/AElf.Cluster.csproj b/src/AElf.Cluster/AElf.Cluster.csproj index 29cf4a6394..b2347f8d45 100644 --- a/src/AElf.Cluster/AElf.Cluster.csproj +++ b/src/AElf.Cluster/AElf.Cluster.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/AElf.ContractTestBase/GenesisSmartContractDtoProvider.cs b/src/AElf.ContractTestBase/GenesisSmartContractDtoProvider.cs index 418fed890e..86e90b3ce2 100644 --- a/src/AElf.ContractTestBase/GenesisSmartContractDtoProvider.cs +++ b/src/AElf.ContractTestBase/GenesisSmartContractDtoProvider.cs @@ -9,11 +9,11 @@ namespace AElf.ContractTestBase public class GenesisSmartContractDtoProvider : IGenesisSmartContractDtoProvider { private readonly IContractDeploymentListProvider _contractDeploymentListProvider; - private readonly IServiceContainer _contractInitializationProviders; + private readonly IEnumerable _contractInitializationProviders; private readonly IContractCodeProvider _contractCodeProvider; public GenesisSmartContractDtoProvider(IContractDeploymentListProvider contractDeploymentListProvider, - IServiceContainer contractInitializationProviders, + IEnumerable contractInitializationProviders, IContractCodeProvider contractCodeProvider) { _contractDeploymentListProvider = contractDeploymentListProvider; diff --git a/src/AElf.Contracts.TestKit/AElf.Contracts.TestKit.csproj b/src/AElf.Contracts.TestKit/AElf.Contracts.TestKit.csproj index 492b799f98..ec89e72ff7 100644 --- a/src/AElf.Contracts.TestKit/AElf.Contracts.TestKit.csproj +++ b/src/AElf.Contracts.TestKit/AElf.Contracts.TestKit.csproj @@ -38,9 +38,9 @@ - - - + + + \ No newline at end of file diff --git a/src/AElf.Contracts.TestKit/ContractTestBase.cs b/src/AElf.Contracts.TestKit/ContractTestBase.cs index e02f954ab9..4d6675ff35 100644 --- a/src/AElf.Contracts.TestKit/ContractTestBase.cs +++ b/src/AElf.Contracts.TestKit/ContractTestBase.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Threading.Tasks; using Acs0; using AElf.Contracts.Deployer; @@ -17,6 +16,7 @@ using MartinCostello.Logging.XUnit; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; +using Volo.Abp.Testing; using Volo.Abp.Threading; using Xunit; using Xunit.Abstractions; diff --git a/src/AElf.Core/AElf.Core.csproj b/src/AElf.Core/AElf.Core.csproj index f42525b1b3..d7db1483c8 100644 --- a/src/AElf.Core/AElf.Core.csproj +++ b/src/AElf.Core/AElf.Core.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj b/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj index e8ccfdd2ce..ce5cfe59cc 100644 --- a/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj +++ b/src/AElf.CrossChain.Core/AElf.CrossChain.Core.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/AElf.CrossChain/CrossChainPlugin.cs b/src/AElf.CrossChain/CrossChainPlugin.cs index ed3910c709..f56196bdca 100644 --- a/src/AElf.CrossChain/CrossChainPlugin.cs +++ b/src/AElf.CrossChain/CrossChainPlugin.cs @@ -18,7 +18,7 @@ public class CrossChainPlugin : IChainInitializationDataPlugin, INodePlugin private readonly ICrossChainRequestService _crossChainRequestService; private readonly List _crossChainCommunicationPlugins; - public CrossChainPlugin(ICrossChainRequestService crossChainRequestService, IServiceContainer crossChainCommunicationPlugins) + public CrossChainPlugin(ICrossChainRequestService crossChainRequestService, IEnumerable crossChainCommunicationPlugins) { _crossChainRequestService = crossChainRequestService; _crossChainCommunicationPlugins = crossChainCommunicationPlugins.ToList(); diff --git a/src/AElf.Database/AElf.Database.csproj b/src/AElf.Database/AElf.Database.csproj index 2774781fa9..d8c6e97689 100644 --- a/src/AElf.Database/AElf.Database.csproj +++ b/src/AElf.Database/AElf.Database.csproj @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/src/AElf.Kernel.CodeCheck/Infrastructure/IContractAuditorContainer.cs b/src/AElf.Kernel.CodeCheck/Infrastructure/IContractAuditorContainer.cs index df612f22d0..fb014c6c2a 100644 --- a/src/AElf.Kernel.CodeCheck/Infrastructure/IContractAuditorContainer.cs +++ b/src/AElf.Kernel.CodeCheck/Infrastructure/IContractAuditorContainer.cs @@ -1,4 +1,5 @@ using System.Collections.Concurrent; +using System.Collections.Generic; namespace AElf.Kernel.CodeCheck.Infrastructure { @@ -12,7 +13,7 @@ public class ContractAuditorContainer : IContractAuditorContainer private readonly ConcurrentDictionary _contractAuditors = new ConcurrentDictionary(); - public ContractAuditorContainer(IServiceContainer contractAuditors) + public ContractAuditorContainer(IEnumerable contractAuditors) { foreach (var auditor in contractAuditors) { diff --git a/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj b/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj index b5c61c8750..c5d6d98ad0 100644 --- a/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj +++ b/src/AElf.Kernel.Core/AElf.Kernel.Core.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/AElf.Kernel.Core/Blockchain/Application/BlockExtraDataService.cs b/src/AElf.Kernel.Core/Blockchain/Application/BlockExtraDataService.cs index 880e9fe703..9b005fd742 100644 --- a/src/AElf.Kernel.Core/Blockchain/Application/BlockExtraDataService.cs +++ b/src/AElf.Kernel.Core/Blockchain/Application/BlockExtraDataService.cs @@ -9,7 +9,7 @@ public class BlockExtraDataService : IBlockExtraDataService { private readonly List _blockExtraDataProviders; - public BlockExtraDataService(IServiceContainer blockExtraDataProviders) + public BlockExtraDataService(IEnumerable blockExtraDataProviders) { _blockExtraDataProviders = blockExtraDataProviders.ToList(); } diff --git a/src/AElf.Kernel.Core/SmartContract/Application/LogEventListeningService.cs b/src/AElf.Kernel.Core/SmartContract/Application/LogEventListeningService.cs index 44276179a7..31b030e681 100644 --- a/src/AElf.Kernel.Core/SmartContract/Application/LogEventListeningService.cs +++ b/src/AElf.Kernel.Core/SmartContract/Application/LogEventListeningService.cs @@ -14,7 +14,7 @@ public class LogEventListeningService : ILogEventListeningService public ILogger> Logger { get; set; } - public LogEventListeningService(IServiceContainer logEventProcessors) + public LogEventListeningService(IEnumerable logEventProcessors) { _logEventProcessors = logEventProcessors.ToLookup(p => p.GetType()).Select(coll => coll.First()).ToList(); } diff --git a/src/AElf.Kernel.FeeCalculation/Application/ResourceTokenFeeService.cs b/src/AElf.Kernel.FeeCalculation/Application/ResourceTokenFeeService.cs index 613b5dce70..3e47bd70ad 100644 --- a/src/AElf.Kernel.FeeCalculation/Application/ResourceTokenFeeService.cs +++ b/src/AElf.Kernel.FeeCalculation/Application/ResourceTokenFeeService.cs @@ -7,9 +7,9 @@ namespace AElf.Kernel.FeeCalculation.Application { public class ResourceTokenFeeService : IResourceTokenFeeService { - private readonly IServiceContainer _resourceTokenFeeProviders; + private readonly IEnumerable _resourceTokenFeeProviders; - public ResourceTokenFeeService(IServiceContainer resourceTokenFeeProviders) + public ResourceTokenFeeService(IEnumerable resourceTokenFeeProviders) { _resourceTokenFeeProviders = resourceTokenFeeProviders; } diff --git a/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/FeeChargePreExecutionPlugin.cs b/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/FeeChargePreExecutionPlugin.cs index 3725c74a40..3376558c51 100644 --- a/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/FeeChargePreExecutionPlugin.cs +++ b/src/AElf.Kernel.SmartContract.ExecutionPluginForMethodFee/FeeChargePreExecutionPlugin.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using AElf.Contracts.MultiToken; using AElf.Kernel.FeeCalculation.Application; @@ -18,7 +17,7 @@ namespace AElf.Kernel.SmartContract.ExecutionPluginForMethodFee { internal class FeeChargePreExecutionPlugin : SmartContractExecutionPluginBase, IPreExecutionPlugin, ISingletonDependency { - private readonly IHostSmartContractBridgeContextService _contextService; + private readonly ISmartContractAddressService _smartContractAddressService; private readonly IPrimaryTokenSymbolProvider _primaryTokenSymbolProvider; private readonly IPrimaryTokenFeeService _txFeeService; private readonly ITransactionFeeExemptionService _transactionFeeExemptionService; @@ -28,7 +27,7 @@ private readonly IContractReaderFactory Logger { get; set; } - public FeeChargePreExecutionPlugin(IHostSmartContractBridgeContextService contextService, + public FeeChargePreExecutionPlugin(ISmartContractAddressService smartContractAddressService, IPrimaryTokenSymbolProvider primaryTokenSymbolProvider, ITransactionFeeExemptionService transactionFeeExemptionService, IPrimaryTokenFeeService txFeeService, @@ -36,7 +35,7 @@ public FeeChargePreExecutionPlugin(IHostSmartContractBridgeContextService contex IContractReaderFactory contractReaderFactory) : base("acs1") { - _contextService = contextService; + _smartContractAddressService = smartContractAddressService; _primaryTokenSymbolProvider = primaryTokenSymbolProvider; _txFeeService = txFeeService; _transactionSizeFeeSymbolsProvider = transactionSizeFeeSymbolsProvider; @@ -50,8 +49,6 @@ public async Task> GetPreTransactionsAsync( { try { - var context = _contextService.Create(); - var chainContext = new ChainContext { BlockHash = transactionContext.PreviousBlockHash, @@ -62,10 +59,10 @@ public async Task> GetPreTransactionsAsync( return new List(); } - context.TransactionContext = transactionContext; - var tokenContractAddress = context.GetContractAddressByName(TokenSmartContractAddressNameProvider.StringName); + var tokenContractAddress = await _smartContractAddressService.GetAddressByContractNameAsync(chainContext, + TokenSmartContractAddressNameProvider.StringName); - if (context.CurrentHeight < AElfConstants.GenesisBlockHeight + 1 || tokenContractAddress == null) + if (transactionContext.BlockHeight < AElfConstants.GenesisBlockHeight + 1 || tokenContractAddress == null) { return new List(); } diff --git a/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPostExecutionPlugin.cs b/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPostExecutionPlugin.cs index 4d9ba0943c..f8bea97f43 100644 --- a/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPostExecutionPlugin.cs +++ b/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPostExecutionPlugin.cs @@ -15,19 +15,19 @@ namespace AElf.Kernel.SmartContract.ExecutionPluginForResourceFee { internal class ResourceConsumptionPostExecutionPlugin : SmartContractExecutionPluginBase, IPostExecutionPlugin, ISingletonDependency { - private readonly IHostSmartContractBridgeContextService _contextService; + private readonly ISmartContractAddressService _smartContractAddressService; private readonly IResourceTokenFeeService _resourceTokenFeeService; private readonly IContractReaderFactory _contractReaderFactory; public ILogger Logger { get; set; } - public ResourceConsumptionPostExecutionPlugin(IHostSmartContractBridgeContextService contextService, + public ResourceConsumptionPostExecutionPlugin(ISmartContractAddressService smartContractAddressService, IResourceTokenFeeService resourceTokenFeeService, IContractReaderFactory contractReaderFactory) : base("acs8") { - _contextService = contextService; + _smartContractAddressService = smartContractAddressService; _resourceTokenFeeService = resourceTokenFeeService; _contractReaderFactory = contractReaderFactory; @@ -41,12 +41,17 @@ public async Task> GetPostTransactionsAsync( { return new List(); } - - var context = _contextService.Create(); - context.TransactionContext = transactionContext; + + var chainContext = new ChainContext + { + BlockHash = transactionContext.PreviousBlockHash, + BlockHeight = transactionContext.BlockHeight - 1 + }; // Generate token contract stub. - var tokenContractAddress = context.GetContractAddressByName(TokenSmartContractAddressNameProvider.StringName); + var tokenContractAddress = + await _smartContractAddressService.GetAddressByContractNameAsync(chainContext, + TokenSmartContractAddressNameProvider.StringName); if (tokenContractAddress == null) { return new List(); @@ -63,19 +68,13 @@ public async Task> GetPostTransactionsAsync( { return new List(); } - - if (transactionContext.Transaction.To == context.Self && - transactionContext.Transaction.MethodName == nameof(ResourceConsumptionContractContainer + + if (transactionContext.Transaction.MethodName == nameof(ResourceConsumptionContractContainer .ResourceConsumptionContractStub.BuyResourceToken)) { return new List(); } - var chainContext = new ChainContext - { - BlockHash = transactionContext.PreviousBlockHash, - BlockHeight = transactionContext.BlockHeight - 1 - }; var chargeResourceTokenInput = new ChargeResourceTokenInput { Caller = transactionContext.Transaction.From diff --git a/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPreExecutionPlugin.cs b/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPreExecutionPlugin.cs index aef11a3940..b1752f5feb 100644 --- a/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPreExecutionPlugin.cs +++ b/src/AElf.Kernel.SmartContract.ExecutionPluginForResourceFee/ResourceConsumptionPreExecutionPlugin.cs @@ -1,10 +1,8 @@ using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Acs8; using AElf.Contracts.MultiToken; using AElf.Kernel.SmartContract.Application; -using AElf.Kernel.SmartContract; using AElf.Kernel.Token; using AElf.Types; using Google.Protobuf; @@ -17,15 +15,15 @@ namespace AElf.Kernel.SmartContract.ExecutionPluginForResourceFee internal class ResourceConsumptionPreExecutionPlugin : SmartContractExecutionPluginBase, IPreExecutionPlugin, ISingletonDependency { - private readonly IHostSmartContractBridgeContextService _contextService; + private readonly ISmartContractAddressService _smartContractAddressService; private readonly IContractReaderFactory _contractReaderFactory; - public ResourceConsumptionPreExecutionPlugin(IHostSmartContractBridgeContextService contextService, + public ResourceConsumptionPreExecutionPlugin(ISmartContractAddressService smartContractAddressService, IContractReaderFactory contractReaderFactory) : base("acs8") { - _contextService = contextService; + _smartContractAddressService = smartContractAddressService; _contractReaderFactory = contractReaderFactory; } @@ -36,12 +34,17 @@ public async Task> GetPreTransactionsAsync( { return new List(); } - - var context = _contextService.Create(); - context.TransactionContext = transactionContext; + + var chainContext = new ChainContext + { + BlockHash = transactionContext.PreviousBlockHash, + BlockHeight = transactionContext.BlockHeight - 1 + }; // Generate token contract stub. - var tokenContractAddress = context.GetContractAddressByName(TokenSmartContractAddressNameProvider.StringName); + var tokenContractAddress = + await _smartContractAddressService.GetAddressByContractNameAsync(chainContext, + TokenSmartContractAddressNameProvider.StringName); if (tokenContractAddress == null) { return new List(); @@ -59,8 +62,7 @@ public async Task> GetPreTransactionsAsync( return new List(); } - if (transactionContext.Transaction.To == context.Self && - transactionContext.Transaction.MethodName == nameof(ResourceConsumptionContractContainer + if (transactionContext.Transaction.MethodName == nameof(ResourceConsumptionContractContainer .ResourceConsumptionContractStub.BuyResourceToken)) { return new List(); diff --git a/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj b/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj index c730d62f40..f879c622b6 100644 --- a/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj +++ b/src/AElf.Kernel.Token/AElf.Kernel.Token.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/AElf.Launcher/AElf.Launcher.csproj b/src/AElf.Launcher/AElf.Launcher.csproj index 83677fcb17..07c749256f 100644 --- a/src/AElf.Launcher/AElf.Launcher.csproj +++ b/src/AElf.Launcher/AElf.Launcher.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/src/AElf.OS.Core/Node/Application/OsBlockchainNodeContextService.cs b/src/AElf.OS.Core/Node/Application/OsBlockchainNodeContextService.cs index e91daa9ff6..4289a1aebd 100644 --- a/src/AElf.OS.Core/Node/Application/OsBlockchainNodeContextService.cs +++ b/src/AElf.OS.Core/Node/Application/OsBlockchainNodeContextService.cs @@ -23,12 +23,12 @@ public class OsBlockchainNodeContextService : IOsBlockchainNodeContextService, I private readonly IBlockchainNodeContextService _blockchainNodeContextService; private readonly IAElfNetworkServer _networkServer; private readonly ISmartContractAddressService _smartContractAddressService; - private readonly IServiceContainer _nodePlugins; + private readonly IEnumerable _nodePlugins; private readonly ContractOptions _contractOptions; public OsBlockchainNodeContextService(IBlockchainNodeContextService blockchainNodeContextService, IAElfNetworkServer networkServer, ISmartContractAddressService smartContractAddressService, - IServiceContainer nodePlugins,IOptionsSnapshot contractOptions) + IEnumerable nodePlugins,IOptionsSnapshot contractOptions) { _blockchainNodeContextService = blockchainNodeContextService; _networkServer = networkServer; diff --git a/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj b/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj index 6e7d6b8361..dee8e9da92 100644 --- a/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj +++ b/src/AElf.OS.Network.Grpc/AElf.OS.Network.Grpc.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/AElf.OS/AElf.OS.csproj b/src/AElf.OS/AElf.OS.csproj index b31648a301..80a482f297 100644 --- a/src/AElf.OS/AElf.OS.csproj +++ b/src/AElf.OS/AElf.OS.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/AElf.OS/BlockSync/Worker/BlockDownloadWorker.cs b/src/AElf.OS/BlockSync/Worker/BlockDownloadWorker.cs index 46571bcdcd..a27299985c 100644 --- a/src/AElf.OS/BlockSync/Worker/BlockDownloadWorker.cs +++ b/src/AElf.OS/BlockSync/Worker/BlockDownloadWorker.cs @@ -9,12 +9,13 @@ using AElf.OS.BlockSync.Types; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.BackgroundWorkers; using Volo.Abp.Threading; namespace AElf.OS.BlockSync.Worker { - public class BlockDownloadWorker : PeriodicBackgroundWorkerBase + public class BlockDownloadWorker : AsyncPeriodicBackgroundWorkerBase { private readonly IBlockchainService _blockchainService; private readonly IBlockDownloadService _blockDownloadService; @@ -25,8 +26,9 @@ public BlockDownloadWorker(AbpTimer timer, IBlockchainService blockchainService, IBlockDownloadService blockDownloadService, IBlockDownloadJobStore blockDownloadJobStore, + IServiceScopeFactory serviceScopeFactory, IOptionsSnapshot blockSyncOptions) - : base(timer) + : base(timer, serviceScopeFactory) { _blockchainService = blockchainService; _blockDownloadService = blockDownloadService; @@ -36,9 +38,9 @@ public BlockDownloadWorker(AbpTimer timer, Timer.Period = _blockSyncOptions.BlockDownloadTimerPeriod; } - protected override void DoWork() + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) { - AsyncHelper.RunSync(ProcessDownloadJobAsync); + await ProcessDownloadJobAsync(); } internal async Task ProcessDownloadJobAsync() diff --git a/src/AElf.OS/Worker/PeerDiscoveryWorker.cs b/src/AElf.OS/Worker/PeerDiscoveryWorker.cs index 778e8a5592..8ce882c7da 100644 --- a/src/AElf.OS/Worker/PeerDiscoveryWorker.cs +++ b/src/AElf.OS/Worker/PeerDiscoveryWorker.cs @@ -2,17 +2,15 @@ using System.Threading.Tasks; using AElf.OS.Network; using AElf.OS.Network.Application; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; -using Org.BouncyCastle.Crypto.Engines; using Volo.Abp.BackgroundWorkers; -using Volo.Abp.DependencyInjection; using Volo.Abp.Threading; namespace AElf.OS.Worker { - public class PeerDiscoveryWorker : PeriodicBackgroundWorkerBase, ISingletonDependency + public class PeerDiscoveryWorker : AsyncPeriodicBackgroundWorkerBase { private readonly IPeerDiscoveryService _peerDiscoveryService; private readonly INetworkService _networkService; @@ -21,7 +19,8 @@ public class PeerDiscoveryWorker : PeriodicBackgroundWorkerBase, ISingletonDepen public new ILogger Logger { get; set; } public PeerDiscoveryWorker(AbpTimer timer, IPeerDiscoveryService peerDiscoveryService, - INetworkService networkService, IReconnectionService reconnectionService) : base(timer) + INetworkService networkService, IReconnectionService reconnectionService, + IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory) { _peerDiscoveryService = peerDiscoveryService; Timer.Period = NetworkConstants.DefaultDiscoveryPeriod; @@ -32,12 +31,12 @@ public PeerDiscoveryWorker(AbpTimer timer, IPeerDiscoveryService peerDiscoverySe Logger = NullLogger.Instance; } - protected override async void DoWork() + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) { - await ProcessPeerDiscoveryJob(); + await ProcessPeerDiscoveryJobAsync(); } - internal async Task ProcessPeerDiscoveryJob() + internal async Task ProcessPeerDiscoveryJobAsync() { var newNodes = await _peerDiscoveryService.DiscoverNodesAsync(); diff --git a/src/AElf.OS/Worker/PeerReconnectionWorker.cs b/src/AElf.OS/Worker/PeerReconnectionWorker.cs index 5dd837c1d7..09a9f6a36c 100644 --- a/src/AElf.OS/Worker/PeerReconnectionWorker.cs +++ b/src/AElf.OS/Worker/PeerReconnectionWorker.cs @@ -10,10 +10,11 @@ using Microsoft.Extensions.Options; using Volo.Abp.BackgroundWorkers; using Volo.Abp.Threading; +using Microsoft.Extensions.DependencyInjection; namespace AElf.OS.Worker { - public class PeerReconnectionWorker : PeriodicBackgroundWorkerBase + public class PeerReconnectionWorker : AsyncPeriodicBackgroundWorkerBase { private readonly IPeerPool _peerPool; private readonly IReconnectionService _reconnectionService; @@ -24,8 +25,9 @@ public class PeerReconnectionWorker : PeriodicBackgroundWorkerBase public new ILogger Logger { get; set; } public PeerReconnectionWorker(AbpTimer timer, IOptionsSnapshot networkOptions, - INetworkService networkService, IPeerPool peerPool, IReconnectionService reconnectionService) - : base(timer) + INetworkService networkService, IPeerPool peerPool, IReconnectionService reconnectionService, + IServiceScopeFactory serviceScopeFactory) + : base(timer, serviceScopeFactory) { _peerPool = peerPool; _reconnectionService = reconnectionService; @@ -35,9 +37,9 @@ public PeerReconnectionWorker(AbpTimer timer, IOptionsSnapshot n timer.Period = _networkOptions.PeerReconnectionPeriod; } - protected override void DoWork() + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) { - AsyncHelper.RunSync(DoReconnectionJobAsync); + await DoReconnectionJobAsync(); } internal async Task DoReconnectionJobAsync() diff --git a/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj b/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj index 0ee447be7e..f07e531701 100644 --- a/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj +++ b/src/AElf.RuntimeSetup/AElf.RuntimeSetup.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj b/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj index c55eb6cec4..ecfa1154a6 100644 --- a/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj +++ b/src/AElf.WebApp.Application.Chain/AElf.WebApp.Application.Chain.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj b/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj index a89e82e160..f8fc5b8c2a 100644 --- a/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj +++ b/src/AElf.WebApp.Application.Core/AElf.WebApp.Application.Core.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj b/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj index 1169cec65c..325af94b96 100644 --- a/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj +++ b/src/AElf.WebApp.Web/AElf.WebApp.Web.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/README.md b/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/README.md index 41b47dc68c..17928d4fc9 100644 --- a/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/README.md +++ b/test/AElf.Contracts.AEDPoSExtension.Demo.Tests/README.md @@ -8,7 +8,7 @@ Since `AElf.Contracts.TestKit` is a contract testing framework for testing AElf Basically add bellowing references: ```MSBUILD - + diff --git a/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj b/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj index fefa31521e..7d6a9850e2 100644 --- a/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj +++ b/test/AElf.Contracts.Economic.AEDPoSExtension.Tests/AElf.Contracts.Economic.AEDPoSExtension.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj b/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj index ebf7c270f8..b20bc9a228 100644 --- a/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj +++ b/test/AElf.CrossChain.Tests/AElf.CrossChain.Tests.csproj @@ -6,10 +6,12 @@ + + - + diff --git a/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj b/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj index 490d72e329..8c54de135d 100644 --- a/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj +++ b/test/AElf.Kernel.SmartContract.Parallel.Tests/AElf.Kernel.SmartContract.Parallel.Tests.csproj @@ -55,14 +55,14 @@ - + - - + + diff --git a/test/AElf.Kernel.SmartContract.Parallel.Tests/ConflictingTransactionIdentificationServiceTest.cs b/test/AElf.Kernel.SmartContract.Parallel.Tests/ConflictingTransactionIdentificationServiceTest.cs index c5d983afdf..5e5a08c783 100644 --- a/test/AElf.Kernel.SmartContract.Parallel.Tests/ConflictingTransactionIdentificationServiceTest.cs +++ b/test/AElf.Kernel.SmartContract.Parallel.Tests/ConflictingTransactionIdentificationServiceTest.cs @@ -6,7 +6,7 @@ using Google.Protobuf; using Microsoft.Extensions.DependencyInjection; using Moq; -using Volo.Abp; +using Volo.Abp.Testing; using Volo.Abp.Modularity; using Xunit; diff --git a/test/AElf.Kernel.SmartContract.Parallel.Tests/ResourceExtractionServiceTest.cs b/test/AElf.Kernel.SmartContract.Parallel.Tests/ResourceExtractionServiceTest.cs index c1673b840f..660086d159 100644 --- a/test/AElf.Kernel.SmartContract.Parallel.Tests/ResourceExtractionServiceTest.cs +++ b/test/AElf.Kernel.SmartContract.Parallel.Tests/ResourceExtractionServiceTest.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using Shouldly; -using Volo.Abp; +using Volo.Abp.Testing; using Xunit; namespace AElf.Kernel.SmartContract.Parallel.Tests diff --git a/test/AElf.Kernel.SmartContract.Parallel.Tests/TransactionGrouperTest.cs b/test/AElf.Kernel.SmartContract.Parallel.Tests/TransactionGrouperTest.cs index d1577fb621..6ec67f9997 100644 --- a/test/AElf.Kernel.SmartContract.Parallel.Tests/TransactionGrouperTest.cs +++ b/test/AElf.Kernel.SmartContract.Parallel.Tests/TransactionGrouperTest.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using Shouldly; -using Volo.Abp; +using Volo.Abp.Testing; using Volo.Abp.Modularity; using Xunit; diff --git a/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj b/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj index 39c7574e9c..cc751b1781 100644 --- a/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj +++ b/test/AElf.Kernel.TransactionPool.Tests/AElf.Kernel.TransactionPool.Tests.csproj @@ -5,7 +5,7 @@ false - + diff --git a/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj b/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj index 4cd8e1aee3..cb0d9d65ef 100644 --- a/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj +++ b/test/AElf.OS.Network.Grpc.Tests/AElf.OS.Network.Grpc.Tests.csproj @@ -5,7 +5,7 @@ - + diff --git a/test/AElf.OS.Tests/AElf.OS.Tests.csproj b/test/AElf.OS.Tests/AElf.OS.Tests.csproj index 9842e2faa3..669464e984 100644 --- a/test/AElf.OS.Tests/AElf.OS.Tests.csproj +++ b/test/AElf.OS.Tests/AElf.OS.Tests.csproj @@ -5,8 +5,8 @@ false - - + + diff --git a/test/AElf.OS.Tests/PeerDiscoveryWorkerTests.cs b/test/AElf.OS.Tests/PeerDiscoveryWorkerTests.cs index b0377fa1e0..784eb99dd9 100644 --- a/test/AElf.OS.Tests/PeerDiscoveryWorkerTests.cs +++ b/test/AElf.OS.Tests/PeerDiscoveryWorkerTests.cs @@ -33,7 +33,7 @@ public async Task ProcessPeerDiscoveryJob_Test() var beforePeers = _networkService.GetPeers().Count; - await _peerDiscoveryWorker.ProcessPeerDiscoveryJob(); + await _peerDiscoveryWorker.ProcessPeerDiscoveryJobAsync(); var afterDiscoveryPeers = _networkService.GetPeers().Count; beforePeers.ShouldBe(afterDiscoveryPeers); diff --git a/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj b/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj index 55353c4f7c..6c75cab510 100644 --- a/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj +++ b/test/AElf.Parallel.Tests/AElf.Parallel.Tests.csproj @@ -5,8 +5,8 @@ 0436 - - + + diff --git a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj index 7bae648b78..6cc8d9fb8e 100644 --- a/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj +++ b/test/AElf.Sdk.CSharp.Tests/AElf.Sdk.CSharp.Tests.csproj @@ -4,7 +4,7 @@ false - + diff --git a/test/AElf.TestBase/AElf.TestBase.csproj b/test/AElf.TestBase/AElf.TestBase.csproj index 4e3303cd76..34feae6467 100644 --- a/test/AElf.TestBase/AElf.TestBase.csproj +++ b/test/AElf.TestBase/AElf.TestBase.csproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/test/AElf.TestBase/AElfIntegratedTest.cs b/test/AElf.TestBase/AElfIntegratedTest.cs index bdfafd9bcd..2bb1cad6cb 100644 --- a/test/AElf.TestBase/AElfIntegratedTest.cs +++ b/test/AElf.TestBase/AElfIntegratedTest.cs @@ -1,5 +1,6 @@ using MartinCostello.Logging.XUnit; using Volo.Abp; +using Volo.Abp.Testing; using Volo.Abp.Modularity; using Xunit.Abstractions; diff --git a/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj b/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj index 2d3fa80f98..99783e11a1 100644 --- a/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj +++ b/test/AElf.WebApp.Application.Net.Tests/AElf.WebApp.Application.Net.Tests.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj b/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj index 2acffe6eb2..024a37de39 100644 --- a/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj +++ b/test/AElf.WebApp.Application.TestBase/AElf.WebApp.Application.TestBase.csproj @@ -7,9 +7,9 @@ - - - + + +