public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IChainService service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService; var model = new ApiChainServerRequestModel(); model.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1); CreateResponse <ApiChainServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.ChainDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiChainServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public BlockCollection(IChainService chainService, ILogger logger = null) { _chainService = chainService; _logger = logger; _heightBefore = BlockChain.GetCurrentBlockHeightAsync().Result; }
public PeerManager(IConnectionListener connectionListener, IChainService chainService, ILogger logger) { _jobQueue = new BlockingCollection <PeerManagerJob>(); _bpAddresses = new List <byte[]>(); _whiteList = new List <byte[]>(); _connectionListener = connectionListener; _chainService = chainService; //_blockChain = blockChain; _logger = logger; _nodeName = NodeConfig.Instance.NodeName; if (!string.IsNullOrWhiteSpace(NetworkConfig.Instance.NetAllowed)) { if (Enum.TryParse(NetworkConfig.Instance.NetAllowed, out AllowedConnection myName)) { _allowedConnections = myName; } } if (NetworkConfig.Instance.NetWhitelist != null) { foreach (var peer in NetworkConfig.Instance.NetWhitelist) { _whiteList.Add(ByteArrayHelpers.FromHexString(peer)); } } SetBpConfig(); }
private void Initialize() { _transactionManager = new TransactionManager(_dataStore, _logger); _transactionReceiptManager = new TransactionReceiptManager(_database); _smartContractManager = new SmartContractManager(_dataStore); _transactionResultManager = new TransactionResultManager(_dataStore); _transactionTraceManager = new TransactionTraceManager(_dataStore); _functionMetadataService = new FunctionMetadataService(_dataStore, _logger); _chainManagerBasic = new ChainManagerBasic(_dataStore); _chainService = new ChainService(_chainManagerBasic, new BlockManagerBasic(_dataStore), _transactionManager, _transactionTraceManager, _dataStore, StateStore); _smartContractRunnerFactory = new SmartContractRunnerFactory(); /*var runner = new SmartContractRunner("../../../../AElf.SDK.CSharp/bin/Debug/netstandard2.0/"); * _smartContractRunnerFactory.AddRunner(0, runner);*/ var runner = new SmartContractRunner(ContractCodes.TestContractFolder); _smartContractRunnerFactory.AddRunner(0, runner); _concurrencyExecutingService = new SimpleExecutingService( new SmartContractService(_smartContractManager, _smartContractRunnerFactory, StateStore, _functionMetadataService), _transactionTraceManager, StateStore, new ChainContextService(_chainService)); _chainCreationService = new ChainCreationService(_chainService, new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory, StateStore, _functionMetadataService), _logger); _binaryMerkleTreeManager = new BinaryMerkleTreeManager(_dataStore); _chainContextService = new ChainContextService(_chainService); _stateStore = new StateStore(_database); }
private void Initialize() { NewStorage(); var transactionManager = new TransactionManager(_dataStore, _logger); var transactionTraceManager = new TransactionTraceManager(_dataStore); _functionMetadataService = new FunctionMetadataService(_dataStore, _logger); var chainManagerBasic = new ChainManagerBasic(_dataStore); ChainService = new ChainService(chainManagerBasic, new BlockManagerBasic(_dataStore), transactionManager, transactionTraceManager, _dataStore, StateStore); _smartContractRunnerFactory = new SmartContractRunnerFactory(); var runner = new SmartContractRunner("../../../../AElf.Runtime.CSharp.Tests.TestContract/bin/Debug/netstandard2.0/"); _smartContractRunnerFactory.AddRunner(0, runner); _chainCreationService = new ChainCreationService(ChainService, new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory, StateStore, _functionMetadataService), _logger); SmartContractManager = new SmartContractManager(_dataStore); Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait(); SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, StateStore, _functionMetadataService); ChainService = new ChainService(new ChainManagerBasic(_dataStore), new BlockManagerBasic(_dataStore), new TransactionManager(_dataStore), new TransactionTraceManager(_dataStore), _dataStore, StateStore); }
public TxValidator(ITxPoolConfig config, IChainService chainService, ILogger logger) { _config = config; _chainService = chainService; _logger = logger; _canonicalBlockHashCache = new CanonicalBlockHashCache(BlockChain, logger); }
public ParentChainBlockInfoRpcServerImpl(IChainService chainService, ILogger logger, IBinaryMerkleTreeManager binaryMerkleTreeManager) { _chainService = chainService; _logger = logger; _binaryMerkleTreeManager = binaryMerkleTreeManager; }
static void Main(string[] args) { try { // Create service collection ServiceCollection serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); // create neo services collection ConfigureNeoServices(serviceCollection); // Create service provider IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); // Run service IEnumerator <IChainService> services = serviceProvider.GetServices <IChainService>().GetEnumerator(); while (services.MoveNext()) { IChainService service = services.Current; service.Run(new Dictionary <string, object>()); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); _logger.LogError(ex.StackTrace); } }
public StoragesTest(IDataStore dataStore, BlockTest blockTest, IChainService chainService, ILogger logger) { _dataStore = dataStore; _blockTest = blockTest; _chainService = chainService; _logger = logger; }
public RecordService(IChainService chainService, ITransactionService transactionService, INodeService nodeService, INetworkService networkService) { _chainService = chainService; _transactionService = transactionService; _nodeService = nodeService; _networkService = networkService; _timer = new Timer(ManagementConfig.Instance.MonitoringInterval * 1000); _timer.Elapsed += TimerOnElapsed; }
public SplashViewModel(IWalletService walletService, ISettingService settingService, IAddressManagerService addressManagerService, IChainService chainService, IOperationTrackerService trackerService) { this.walletService = walletService; this.settingService = settingService; this.addressManagerService = addressManagerService; this.chainService = chainService; this.trackerService = trackerService; AppName = "CoinBag"; }
public GameService(ILoggerFactory loggerFactory, IMapper mapper, IGameService defaultGameService, IEntryService defaultEntryService, IEventService defaultEventService, IChainService defaultChainService) { _mapper = mapper; _logger = loggerFactory.CreateLogger <GameService>(); _defaultGameService = defaultGameService; _defaultEntryService = defaultEntryService; _defaultEventService = defaultEventService; _defaultChainService = defaultChainService; }
public MainchainNodeService(IStateStore stateStore, ITxHub hub, IChainCreationService chainCreationService, IBlockSynchronizer blockSynchronizer, IChainService chainService, IMiner miner, ILogger logger) { _stateStore = stateStore; _chainCreationService = chainCreationService; _chainService = chainService; _txHub = hub; _logger = logger; _miner = miner; _blockSynchronizer = blockSynchronizer; }
public AbstractChainController( ApiSettings settings, ILogger <AbstractChainController> logger, ITransactionCoordinator transactionCoordinator, IChainService chainService, IApiChainModelMapper chainModelMapper ) : base(settings, logger, transactionCoordinator) { this.ChainService = chainService; this.ChainModelMapper = chainModelMapper; }
public BlockExecutor(IChainService chainService, IExecutingService executingService, ITransactionResultManager transactionResultManager, ClientManager clientManager, IBinaryMerkleTreeManager binaryMerkleTreeManager, ITxHub txHub, IChainManagerBasic chainManagerBasic, IStateStore stateStore) { _chainService = chainService; _executingService = executingService; _transactionResultManager = transactionResultManager; _clientManager = clientManager; _binaryMerkleTreeManager = binaryMerkleTreeManager; _txHub = txHub; _chainManagerBasic = chainManagerBasic; _stateStore = stateStore; _dpoSInfoProvider = new DPoSInfoProvider(_stateStore); _logger = LogManager.GetLogger(nameof(BlockExecutor)); MessageHub.Instance.Subscribe <DPoSStateChanged>(inState => _isMining = inState.IsMining); _executing = false; _prepareTerminated = false; _terminated = false; MessageHub.Instance.Subscribe <TerminationSignal>(signal => { if (signal.Module == TerminatedModuleEnum.BlockExecutor) { if (!_executing) { _terminated = true; MessageHub.Instance.Publish(new TerminatedModule(TerminatedModuleEnum.BlockExecutor)); } else { _prepareTerminated = true; } } }); MessageHub.Instance.Subscribe <StateEvent>(inState => { if (inState == StateEvent.RollbackFinished) { _isLimitExecutionTime = false; } if (inState == StateEvent.MiningStart) { _isLimitExecutionTime = true; } _logger?.Trace($"Current Event: {inState.ToString()} ,IsLimitExecutionTime: {_isLimitExecutionTime}"); }); }
public MainViewModel(IAddressManagerService addressManagerService, IChainService chainService, IOperationTrackerService trackerService, IWalletService walletService) { this.addressManagerService = addressManagerService; this.chainService = chainService; this.trackerService = trackerService; this.walletService = walletService; Title = "Coin bag"; RecentTransactions = new ObservableRangeCollection <TransactionDetail>(); GoToGetCoinCommand = new Command(GoToGetCoinCommandExecute); GoToSendCoinCommand = new Command(GoToSendCoinCommandExecute); }
public TxHub(ITransactionManager transactionManager, ITransactionReceiptManager receiptManager, IChainService chainService, ITxSignatureVerifier signatureVerifier, ITxRefBlockValidator refBlockValidator) { _transactionManager = transactionManager; _receiptManager = receiptManager; _chainService = chainService; _signatureVerifier = signatureVerifier; _refBlockValidator = refBlockValidator; _terminated = false; }
public RecordService(IChainService chainService, ITransactionService transactionService, INodeService nodeService, INetworkService networkService, IOptionsSnapshot <ManagementOptions> options) { Logger = NullLogger <RecordService> .Instance; _chainService = chainService; _transactionService = transactionService; _nodeService = nodeService; _networkService = networkService; _managementOptions = options.Value; _timer = new Timer(_managementOptions.MonitoringInterval * 1000); _timer.Elapsed += TimerOnElapsed; }
public ChainController( ApiSettings settings, ILogger <ChainController> logger, ITransactionCoordinator transactionCoordinator, IChainService chainService, IApiChainServerModelMapper chainModelMapper ) : base(settings, logger, transactionCoordinator) { this.ChainService = chainService; this.ChainModelMapper = chainModelMapper; this.BulkInsertLimit = 250; this.MaxLimit = 1000; this.DefaultLimit = 250; }
public TransactionResultTest(ITxPoolConfig txPoolConfig, IChainService chainService, ITxSignatureVerifier signatureVerifier, ITxRefBlockValidator refBlockValidator, ITransactionResultManager transactionResultManager, ITxHub txHub) { ChainConfig.Instance.ChainId = Hash.Generate().DumpHex(); NodeConfig.Instance.NodeAccount = Address.Generate().DumpHex(); _transactionResultManager = transactionResultManager; _signatureVerifier = signatureVerifier; _refBlockValidator = refBlockValidator; _txHub = txHub; // _transactionResultService = new TransactionResultService( // new TxPool(logger, // new NewTxHub(transactionManager, chainService, signatureVerifier, refBlockValidator)), transactionResultManager); _transactionResultService = new TransactionResultService(_txHub, _transactionResultManager); }
public ContractTest(IStateStore stateStore, IChainCreationService chainCreationService, IChainService chainService, ITransactionManager transactionManager, ISmartContractManager smartContractManager, IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory) { _stateStore = stateStore; _chainCreationService = chainCreationService; _chainService = chainService; _transactionManager = transactionManager; _smartContractManager = smartContractManager; _chainContextService = chainContextService; _functionMetadataService = functionMetadataService; _smartContractRunnerFactory = smartContractRunnerFactory; _smartContractService = new SmartContractService(_smartContractManager, _smartContractRunnerFactory, stateStore, _functionMetadataService); }
public BlockExecutionService(IExecutingService executingService, ITxPoolService txPoolService, IChainService chainService, ITransactionManager transactionManager, ITransactionResultManager transactionResultManager, IStateDictator stateDictator, IBinaryMerkleTreeManager binaryMerkleTreeManager) { _executingService = executingService; _txPoolService = txPoolService; _chainService = chainService; _transactionManager = transactionManager; _transactionResultManager = transactionResultManager; _stateDictator = stateDictator; _binaryMerkleTreeManager = binaryMerkleTreeManager; _logger = LogManager.GetLogger(nameof(BlockExecutionService)); }
public MockSetup(IDataStore dataStore, IChainCreationService chainCreationService, IChainService chainService, IActorEnvironment actorEnvironment, IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger, IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager) { _logger = logger; _stateStore = stateStore; ActorEnvironment = actorEnvironment; if (!ActorEnvironment.Initialized) { ActorEnvironment.InitActorSystem(); } _hashManager = hashManager; _transactionManager = transactionManager; _chainCreationService = chainCreationService; _chainService = chainService; ChainContextService = chainContextService; _functionMetadataService = functionMetadataService; _smartContractRunnerFactory = smartContractRunnerFactory; SmartContractManager = new SmartContractManager(dataStore); Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait(); SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore, functionMetadataService); Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait(); ServicePack = new ServicePack() { ChainContextService = chainContextService, SmartContractService = SmartContractService, ResourceDetectionService = new NewMockResourceUsageDetectionService(), StateStore = _stateStore }; // These are only required for workertest // other tests use ActorEnvironment var workers = new[] { "/user/worker1", "/user/worker2" }; Worker1 = Sys.ActorOf(Props.Create <Worker>(), "worker1"); Worker2 = Sys.ActorOf(Props.Create <Worker>(), "worker2"); Router = Sys.ActorOf(Props.Empty.WithRouter(new TrackedGroup(workers)), "router"); Worker1.Tell(new LocalSerivcePack(ServicePack)); Worker2.Tell(new LocalSerivcePack(ServicePack)); Requestor = Sys.ActorOf(AElf.Execution.Execution.Requestor.Props(Router)); }
public BlockChainTests_MockSetup(IDataStore dataStore, IChainCreationService chainCreationService, IChainService chainService, IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger, IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager) { _logger = logger; _stateStore = stateStore; _hashManager = hashManager; _transactionManager = transactionManager; _chainCreationService = chainCreationService; ChainService = chainService; ChainContextService = chainContextService; _functionMetadataService = functionMetadataService; _smartContractRunnerFactory = smartContractRunnerFactory; SmartContractManager = new SmartContractManager(dataStore); Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait(); SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore, functionMetadataService); Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait(); }
public Miner(IMinerConfig config, ITxHub txHub, IChainService chainService, IExecutingService executingService, ITransactionResultManager transactionResultManager, ILogger logger, ClientManager clientManager, IBinaryMerkleTreeManager binaryMerkleTreeManager, ServerManager serverManager, IBlockValidationService blockValidationService, IChainContextService chainContextService, IChainManagerBasic chainManagerBasic, IStateStore stateStore) { Config = config; _txHub = txHub; _chainService = chainService; _executingService = executingService; _transactionResultManager = transactionResultManager; _logger = logger; _clientManager = clientManager; _binaryMerkleTreeManager = binaryMerkleTreeManager; _serverManager = serverManager; _blockValidationService = blockValidationService; _chainContextService = chainContextService; _chainManagerBasic = chainManagerBasic; _txFilter = new TransactionFilter(); _dpoSInfoProvider = new DPoSInfoProvider(stateStore); _maxMineTime = ConsensusConfig.Instance.DPoSMiningInterval * NodeConfig.Instance.RatioMine; }
public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); var mapper = new ApiChainServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IChainService service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService; ApiChainServerResponseModel model = await service.Get(1); ApiChainClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1); UpdateResponse <ApiChainClientResponseModel> updateResponse = await client.ChainUpdateAsync(model.Id, request); context.Entry(context.Set <Chain>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Chain>().ToList()[0].ChainStatusId.Should().Be(1); context.Set <Chain>().ToList()[0].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); context.Set <Chain>().ToList()[0].Name.Should().Be("B"); context.Set <Chain>().ToList()[0].TeamId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.ChainStatusId.Should().Be(1); updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); updateResponse.Record.Name.Should().Be("B"); updateResponse.Record.TeamId.Should().Be(1); }
public BlockchainApiController(IChainService chainService, ILogger <BlockchainApiController> logger, IMapperService mapper) { _chainService = chainService; _logger = logger; _mapper = mapper; }
public ChainController(IChainService chainService) { _chainService = chainService; }
public BlockTest(IChainService chainService, IChainCreationService chainCreationService) { //_smartContractZero = smartContractZero; _chainCreationService = chainCreationService; _chainService = chainService; }
public DPoS(IStateStore stateStore, ITxHub txHub, IMiner miner, IChainService chainService) { _txHub = txHub; _miner = miner; _chainService = chainService; _prepareTerminated = false; _terminated = false; _logger = LogManager.GetLogger(nameof(DPoS)); Helper = new AElfDPoSHelper(Hash.LoadHex(ChainConfig.Instance.ChainId), Miners, ContractAddress, stateStore); Provider = new DPoSInfoProvider(stateStore); var count = MinersConfig.Instance.Producers.Count; GlobalConfig.BlockProducerNumber = count; GlobalConfig.BlockNumberOfEachRound = count + 1; _logger?.Info("Block Producer nodes count:" + GlobalConfig.BlockProducerNumber); _logger?.Info("Blocks of one round:" + GlobalConfig.BlockNumberOfEachRound); if (GlobalConfig.BlockProducerNumber == 1 && NodeConfig.Instance.IsMiner) { AElfDPoSObserver.RecoverMining(); } MessageHub.Instance.Subscribe <UpdateConsensus>(async option => { if (option == UpdateConsensus.Update) { _logger?.Trace("UpdateConsensus - Update"); await Update(); } if (option == UpdateConsensus.Dispose) { _logger?.Trace("UpdateConsensus - Dispose"); Stop(); } }); MessageHub.Instance.Subscribe <LockMining>(async inState => { if (inState.Lock) { IncrementLockNumber(); } else { await Start(); } }); MessageHub.Instance.Subscribe <TerminationSignal>(signal => { if (signal.Module == TerminatedModuleEnum.Mining) { _prepareTerminated = true; } }); MessageHub.Instance.Subscribe <FSMStateChanged>(inState => { CurrentState = inState.CurrentState; }); }