public OSTestHelper(IOsBlockchainNodeContextService osBlockchainNodeContextService,
                            IAccountService accountService,
                            IMinerService minerService,
                            IBlockchainService blockchainService,
                            ISmartContractAddressService smartContractAddressService,
                            IBlockAttachService blockAttachService,
                            IStaticChainInformationProvider staticChainInformationProvider,
                            ITransactionResultService transactionResultService,
                            IOptionsSnapshot <ChainOptions> chainOptions,
                            ITransactionPoolService transactionPoolService)
        {
            _chainOptions = chainOptions.Value;
            _osBlockchainNodeContextService = osBlockchainNodeContextService;
            _accountService                 = accountService;
            _minerService                   = minerService;
            _blockchainService              = blockchainService;
            _smartContractAddressService    = smartContractAddressService;
            _blockAttachService             = blockAttachService;
            _staticChainInformationProvider = staticChainInformationProvider;
            _transactionResultService       = transactionResultService;
            _transactionPoolService         = transactionPoolService;

            BestBranchBlockList = new List <Block>();
            ForkBranchBlockList = new List <Block>();
            NotLinkedBlockList  = new List <Block>();
        }
        public async Task GlobalSetup()
        {
            _chains = GetRequiredService <IBlockchainStore <Chain> >();
            _chainStateInfoCollection = GetRequiredService <IStateStore <ChainStateInfo> >();
            _blockchainStateService   = GetRequiredService <IBlockchainStateService>();
            _blockStateSetManger      = GetRequiredService <IBlockStateSetManger>();
            _blockchainService        = GetRequiredService <IBlockchainService>();
            _osTestHelper             = GetRequiredService <OSTestHelper>();
            _chainManager             = GetRequiredService <IChainManager>();
            _blockManager             = GetRequiredService <IBlockManager>();
            _transactionManager       = GetRequiredService <ITransactionManager>();
            _transactionPoolService   = GetRequiredService <ITransactionPoolService>();


            _blockStateSets = new List <BlockStateSet>();
            _blocks         = new List <Block>();

            _chain = await _blockchainService.GetChainAsync();

            var blockHash = _chain.BestChainHash;

            while (true)
            {
                var blockState = await _blockStateSetManger.GetBlockStateSetAsync(blockHash);

                _blockStateSets.Add(blockState);

                var blockHeader = await _blockchainService.GetBlockHeaderByHashAsync(blockHash);

                blockHash = blockHeader.PreviousBlockHash;
                if (blockHash == _chain.LastIrreversibleBlockHash)
                {
                    break;
                }
            }

            await _blockchainStateService.MergeBlockStateAsync(_chain.BestChainHeight, _chain.BestChainHash);

            for (var i = 0; i < BlockCount; i++)
            {
                var transactions = await _osTestHelper.GenerateTransferTransactions(TransactionCount);

                await _osTestHelper.BroadcastTransactions(transactions);

                var block = await _osTestHelper.MinedOneBlock();

                _blocks.Add(block);

                var blockState = await _blockStateSetManger.GetBlockStateSetAsync(block.GetHash());

                _blockStateSets.Add(blockState);
            }

            var chain = await _blockchainService.GetChainAsync();

            await _chainManager.SetIrreversibleBlockAsync(chain, chain.BestChainHash);

            _chainStateInfo = await _chainStateInfoCollection.GetAsync(chain.Id.ToStorageKey());
        }
 public MiningWithTransactionsBenchmarkBase()
 {
     TransactionPoolService          = GetRequiredService <ITransactionPoolService>();
     _osBlockchainNodeContextService = GetRequiredService <IOsBlockchainNodeContextService>();
     _accountService              = GetRequiredService <IAccountService>();
     BlockchainService            = GetRequiredService <IBlockchainService>();
     _smartContractAddressService = GetRequiredService <ISmartContractAddressService>();
 }
示例#4
0
        public async Task GlobalSetup()
        {
            _blockchainService      = GetRequiredService <IBlockchainService>();
            _osTestHelper           = GetRequiredService <OSTestHelper>();
            _transactionManager     = GetRequiredService <ITransactionManager>();
            _transactionPoolService = GetRequiredService <ITransactionPoolService>();

            _chain = await _blockchainService.GetChainAsync();
        }
示例#5
0
 public MinerServiceTests()
 {
     _transactionPoolService           = GetRequiredService <ITransactionPoolService>();
     _blockTransactionLimitProvider    = GetRequiredService <IBlockTransactionLimitProvider>();
     _transactionPackingOptionProvider = GetRequiredService <ITransactionPackingOptionProvider>();
     _minerService        = GetRequiredService <IMinerService>();
     _blockStateSetManger = GetRequiredService <IBlockStateSetManger>();
     _blockchainService   = GetRequiredService <IBlockchainService>();
     _kernelTestHelper    = GetRequiredService <KernelTestHelper>();
 }
示例#6
0
        public async Task GlobalSetup()
        {
            _blockchainService      = GetRequiredService <IBlockchainService>();
            _osTestHelper           = GetRequiredService <OSTestHelper>();
            _minerService           = GetRequiredService <IMinerService>();
            _blockStateSets         = GetRequiredService <INotModifiedCachedStateStore <BlockStateSet> >();
            _transactionManager     = GetRequiredService <ITransactionManager>();
            _transactionPoolService = GetRequiredService <ITransactionPoolService>();

            _transactions = new List <Transaction>();
            _chain        = await _blockchainService.GetChainAsync();
        }
        public MinerService(IMiningService miningService,
                            IBlockTransactionLimitProvider blockTransactionLimitProvider,
                            ITransactionPackingOptionProvider transactionPackingOptionProvider,
                            ITransactionPoolService transactionPoolService)
        {
            _miningService = miningService;
            _blockTransactionLimitProvider    = blockTransactionLimitProvider;
            _transactionPackingOptionProvider = transactionPackingOptionProvider;
            _transactionPoolService           = transactionPoolService;

            Logger = NullLogger <MinerService> .Instance;
        }
        public BlockChainAppService(IBlockchainService blockchainService,
                                    IBlockStateSetManger blockStateSetManger,
                                    ITransactionPoolService transactionPoolService,
                                    IObjectMapper <ChainApplicationWebAppAElfModule> objectMapper)
        {
            _blockchainService      = blockchainService;
            _blockStateSetManger    = blockStateSetManger;
            _transactionPoolService = transactionPoolService;
            _objectMapper           = objectMapper;

            Logger        = NullLogger <BlockChainAppService> .Instance;
            LocalEventBus = NullLocalEventBus.Instance;
        }
 public ParallelTestHelper(IOsBlockchainNodeContextService osBlockchainNodeContextService,
                           IAccountService accountService,
                           IMinerService minerService,
                           IBlockchainService blockchainService,
                           ISmartContractAddressService smartContractAddressService,
                           IBlockAttachService blockAttachService,
                           IStaticChainInformationProvider staticChainInformationProvider,
                           ITransactionResultService transactionResultService,
                           IOptionsSnapshot <ChainOptions> chainOptions,
                           ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService,
                           ITransactionPoolService transactionPoolService
                           ) : base(osBlockchainNodeContextService, accountService,
                                    minerService, blockchainService, smartContractAddressService, blockAttachService,
                                    staticChainInformationProvider, transactionResultService, chainOptions, transactionPoolService)
 {
     _accountService = accountService;
     _staticChainInformationProvider      = staticChainInformationProvider;
     _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService;
     _smartContractAddressService         = smartContractAddressService;
 }
 public TransactionResultProxyService(ITransactionPoolService transactionPoolService,
                                      ITransactionResultQueryService transactionResultQueryService)
 {
     TransactionPoolService        = transactionPoolService;
     TransactionResultQueryService = transactionResultQueryService;
 }
示例#11
0
 public TxPoolInterestedEventsHandler(ITransactionPoolService transactionPoolService)
 {
     _transactionPoolService = transactionPoolService;
 }