Example #1
0
        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);
        }
 public ParentChainBlockInfoRpcServerImpl(IChainService chainService, ILogger logger,
                                          IBinaryMerkleTreeManager binaryMerkleTreeManager)
 {
     _chainService            = chainService;
     _logger                  = logger;
     _binaryMerkleTreeManager = binaryMerkleTreeManager;
 }
Example #3
0
        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}");
            });
        }
Example #4
0
        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));
        }
Example #5
0
File: Miner.cs Project: wyk125/AElf
        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;
        }