public void Setup(BenchmarkContext context) { _blockchainStateMergingService = GetRequiredService <IBlockchainStateMergingService>(); _blockchainService = GetRequiredService <IBlockchainService>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _chainManager = GetRequiredService <IChainManager>(); _counter = context.GetCounter("TestCounter"); AsyncHelper.RunSync(async() => { var transactions = await _osTestHelper.GenerateTransferTransactions(1000); await _osTestHelper.BroadcastTransactions(transactions); await _osTestHelper.MinedOneBlock(); var chain = await _blockchainService.GetChainAsync(); await _chainManager.SetIrreversibleBlockAsync(chain, chain.BestChainHash); }); }
public static async Task <List <IBlockIndex> > GetBlockIndexesAsync(this IBlockchainService blockchainService, long firstHeight, Hash bestChainHash, long bestChainHeight) { if (firstHeight == 0) { return(new List <IBlockIndex>()); } var indexCount = bestChainHeight - firstHeight; var blockIndexes = await blockchainService.GetReversedBlockIndexes(bestChainHash, (int)indexCount); blockIndexes.Add(new BlockIndex { BlockHash = bestChainHash, BlockHeight = bestChainHeight }); return(blockIndexes); }
public void Setup(BenchmarkContext context) { _osTestHelper = GetRequiredService <OSTestHelper>(); _txHub = GetRequiredService <ITxHub>(); _blockchainService = GetRequiredService <IBlockchainService>(); _counter = context.GetCounter("TestCounter"); AsyncHelper.RunSync(async() => { var transactions = await _osTestHelper.GenerateTransferTransactions(1000); await _txHub.HandleTransactionsReceivedAsync(new TransactionsReceivedEvent { Transactions = transactions }); await _osTestHelper.MinedOneBlock(); }); }
public BlockchainIndexingService( IBalanceObservationTaskRepository balanceObservationTaskRepository, IBlockchainService blockchainServiceService, IBlockIndexationLockRepository blockLockRepository, IChaosKitty chaosKitty, ILogFactory logFactory, Settings settings, IBlockchainIndexationStateRepository stateRepository, ITransactionReceiptRepository transactionReceiptRepository) { _balanceObservationTaskRepository = balanceObservationTaskRepository; _blockchainService = blockchainServiceService; _blockLockDuration = settings.BlockLockDuration; _blockLockRepository = blockLockRepository; _chaosKitty = chaosKitty; _log = logFactory.CreateLog(this); _stateRepository = stateRepository; _telemetryClient = new TelemetryClient(); _transactionReceiptRepository = transactionReceiptRepository; }
public ParallelTestHelper(IOsBlockchainNodeContextService osBlockchainNodeContextService, IAccountService accountService, IMinerService minerService, IBlockchainService blockchainService, ITxHub txHub, ISmartContractAddressService smartContractAddressService, IBlockAttachService blockAttachService, IStaticChainInformationProvider staticChainInformationProvider, ITransactionResultService transactionResultService, IOptionsSnapshot <ChainOptions> chainOptions, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService ) : base(osBlockchainNodeContextService, accountService, minerService, blockchainService, txHub, smartContractAddressService, blockAttachService, staticChainInformationProvider, transactionResultService, chainOptions) { _accountService = accountService; _staticChainInformationProvider = staticChainInformationProvider; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _smartContractAddressService = smartContractAddressService; }
public BlockChainAppService(IBlockchainService blockchainService, ISmartContractAddressService smartContractAddressService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, ITransactionManager transactionManager, ITransactionResultQueryService transactionResultQueryService, ITxHub txHub, IBlockchainStateManager blockchainStateManager ) { _blockchainService = blockchainService; _smartContractAddressService = smartContractAddressService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; _transactionManager = transactionManager; _transactionResultQueryService = transactionResultQueryService; _txHub = txHub; _blockchainStateManager = blockchainStateManager; Logger = NullLogger <BlockChainAppService> .Instance; LocalEventBus = NullLocalEventBus.Instance; }
public async Task <TransactionAmountCalculationResult> ExecuteAsync(IBlockchainService blockchainService, string @from, BigInteger transferAmount, BigInteger gasAmount, bool includeFee) { var result = transferAmount; if (includeFee) { // ReSharper disable once UnusedVariable var gasStepPrice = await blockchainService.EstimateGasPriceAsync(); var transactionCost = gasAmount * gasStepPrice; result -= transactionCost; } if (result <= 0) { return(TransactionAmountCalculationResult.TransactionAmountIsTooSmall()); } return(TransactionAmountCalculationResult.TransactionAmount(result)); }
public SmartContractExecutiveService(IDeployedContractAddressProvider deployedContractAddressProvider, IDefaultContractZeroCodeProvider defaultContractZeroCodeProvider, ISmartContractRunnerContainer smartContractRunnerContainer, IHostSmartContractBridgeContextService hostSmartContractBridgeContextService, IChainBlockLinkService chainBlockLinkService, IBlockchainService blockchainService, ISmartContractCodeHistoryService smartContractCodeHistoryService, ISmartContractRegistrationCacheProvider smartContractRegistrationCacheProvider, ISmartContractExecutiveProvider smartContractExecutiveProvider) { _deployedContractAddressProvider = deployedContractAddressProvider; _defaultContractZeroCodeProvider = defaultContractZeroCodeProvider; _smartContractRunnerContainer = smartContractRunnerContainer; _hostSmartContractBridgeContextService = hostSmartContractBridgeContextService; _chainBlockLinkService = chainBlockLinkService; _blockchainService = blockchainService; _smartContractCodeHistoryService = smartContractCodeHistoryService; _smartContractRegistrationCacheProvider = smartContractRegistrationCacheProvider; _smartContractExecutiveProvider = smartContractExecutiveProvider; Logger = new NullLogger <SmartContractExecutiveService>(); }
public DefaultTransactionService( IAddressService addressService, IBlockchainService blockchainService, IChaosKitty chaosKitty, ILogFactory logFactory, ITransactionMonitoringTaskRepository transactionMonitoringTaskRepository, ITransactionRepository transactionRepository, IBuildTransactionStrategy buildTransactionStrategy, ICalculateGasAmountStrategy calculateGasAmountStrategy, ICalculateTransactionAmountStrategy calculateTransactionAmountStrategy) { _addressService = addressService; _blockchainService = blockchainService; _chaosKitty = chaosKitty; _log = logFactory.CreateLog(this); _transactionMonitoringTaskRepository = transactionMonitoringTaskRepository; _transactionRepository = transactionRepository; _buildTransactionStrategy = buildTransactionStrategy; _calculateGasAmountStrategy = calculateGasAmountStrategy; _calculateTransactionAmountStrategy = calculateTransactionAmountStrategy; }
public void Setup(BenchmarkContext context) { _blockchainService = GetRequiredService <IBlockchainService>(); _blockchainExecutingService = GetRequiredService <IBlockchainExecutingService>(); _chainManager = GetRequiredService <IChainManager>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _counter = context.GetCounter("TestCounter"); AsyncHelper.RunSync(async() => { var chain = await _blockchainService.GetChainAsync(); var transactions = await _osTestHelper.GenerateTransferTransactions(1000); _block = _osTestHelper.GenerateBlock(chain.BestChainHash, chain.BestChainHeight, transactions); await _blockchainService.AddBlockAsync(_block); chain = await _blockchainService.GetChainAsync(); await _blockchainService.AttachBlockToChainAsync(chain, _block); }); }
public TransactionService( IAddressService addressService, IBlockchainService blockchainService, IChaosKitty chaosKitty, ILogFactory logFactory, Settings settings, ITransactionMonitoringTaskRepository transferTransactionMonitoringTaskRepository, ITransactionRepository transactionRepository) { _addressService = addressService; _blockchainService = blockchainService; _chaosKitty = chaosKitty; _gasAmountLock = new SemaphoreSlim(1); _gasAmountReservePercentage = settings.GasAmountReservePercentage; _log = logFactory.CreateLog(this); _maxGasAmount = BigInteger.Parse(settings.MaxGasAmountManager.CurrentValue); _maxGasAmountManager = settings.MaxGasAmountManager; _minimalTransactionAmount = settings.MinimalTransactionAmount; _transferTransactionMonitoringTaskRepository = transferTransactionMonitoringTaskRepository; _transactionRepository = transactionRepository; ValidateMaxGasAmount(_maxGasAmount); }
public DefaultBlockchainIndexingService( IBalanceMonitoringTaskRepository balanceMonitoringTaskRepository, IBalanceRepository balanceRepository, IBlockchainIndexationStateRepository stateRepository, IBlockchainService blockchainServiceService, IBlockIndexationLockRepository blockLockRepository, IChaosKitty chaosKitty, IIndexBlockStrategy indexBlockStrategy, ILogFactory logFactory, Settings settings, ITransactionReceiptRepository transactionReceiptRepository) { _balanceRepository = balanceRepository; _balanceMonitoringTaskRepository = balanceMonitoringTaskRepository; _blockchainService = blockchainServiceService; _blockLockDuration = settings.BlockLockDuration; _blockLockRepository = blockLockRepository; _chaosKitty = chaosKitty; _indexBlockStrategy = indexBlockStrategy; _log = logFactory.CreateLog(this); _minBlockNumberToIndex = settings.MinBlockNumberToIndex; _stateRepository = stateRepository; _transactionReceiptRepository = transactionReceiptRepository; }
internal static async Task <MethodDescriptor> GetContractMethodDescriptorAsync( IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService, Address contractAddress, string methodName, bool throwException = true) { IEnumerable <FileDescriptor> fileDescriptors; _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; try { fileDescriptors = await GetFileDescriptorsAsync(contractAddress); } catch { if (throwException) { throw new UserFriendlyException(Error.Message[Error.InvalidContractAddress], Error.InvalidContractAddress.ToString()); } return(null); } foreach (var fileDescriptor in fileDescriptors) { var method = fileDescriptor.Services.Select(s => s.FindMethodByName(methodName)).FirstOrDefault(); if (method == null) { continue; } return(method); } return(null); }
public TestDataProvider(IBlockTimeProvider blockTimeProvider, ITransactionListProvider transactionListProvider, IAElfAsymmetricCipherKeyPairProvider keyPairProvider, IBlockchainService blockchainService) { _blockTimeProvider = blockTimeProvider; _transactionListProvider = transactionListProvider; _keyPairProvider = keyPairProvider; _blockchainService = blockchainService; }
public TransactionsController(IBlockchainService blockchainService) : base(blockchainService) { }
public void GetBlockchainService() { IBlockchainService service = clientWithMock.GetBlockChainService(); Assert.IsNotNull(service); }
public TransactionToHubTests(ITestOutputHelper outputHelper) : base(outputHelper) { _blockchainService = GetRequiredService <IBlockchainService>(); _smartContractAddressService = GetRequiredService <ISmartContractAddressService>(); _osTestHelper = GetRequiredService <OSTestHelper>(); }
public async Task GlobalSetup() { _chains = GetRequiredService <IBlockchainStore <Chain> >(); _chainStateInfoCollection = GetRequiredService <IStateStore <ChainStateInfo> >(); _blockchainStateManager = GetRequiredService <IBlockchainStateManager>(); _blockchainStateService = GetRequiredService <IBlockchainStateService>(); _blockStateSetManger = GetRequiredService <IBlockStateSetManger>(); _blockchainService = GetRequiredService <IBlockchainService>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _chainManager = GetRequiredService <IChainManager>(); _blockManager = GetRequiredService <IBlockManager>(); _transactionManager = GetRequiredService <ITransactionManager>(); _transactionResultManager = GetRequiredService <ITransactionResultManager>(); _txHub = GetRequiredService <ITxHub>(); _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 BlockValidationProvider(IBlockchainService blockchainService, ITransactionBlockIndexService transactionBlockIndexService) { _blockchainService = blockchainService; _transactionBlockIndexService = transactionBlockIndexService; }
public Blockchain(List <IBlock> chain, List <ITransaction> currentTransactions, IBlockchainService service) { _chain = chain; _currentTransactions = currentTransactions; _nodes = new HashSet <string>(); _blockchainService = service; CreateBlock(1, "100"); }
public HomeController(IBlockchainService service) { this._service = service; }
public ContractFileDescriptorSetAppService(IBlockchainService blockchainService, ITransactionReadOnlyExecutionService transactionReadOnlyExecutionService) { _blockchainService = blockchainService; _transactionReadOnlyExecutionService = transactionReadOnlyExecutionService; }
public PeersController(IBlockchainService blockchainService) : base(blockchainService) { }
public SideChainPrimaryTokenSymbolProvider(ITokenContractReaderFactory tokenContractReaderFactory, IBlockchainService blockchainService) { _tokenContractReaderFactory = tokenContractReaderFactory; _blockchainService = blockchainService; }
internal static async Task <Block> GetBlockAsync(this IBlockchainService blockchainService, Hash blockHash) { return(await blockchainService.GetBlockByHashAsync(blockHash)); }
public TransactionBlockIndexService(IBlockchainService blockchainService, ITransactionBlockIndexManager transactionBlockIndexManager) { _blockchainService = blockchainService; _transactionBlockIndexManager = transactionBlockIndexManager; }
public TxHubTests() { _txHub = GetRequiredService <TxHub>(); _blockchainService = GetRequiredService <IBlockchainService>(); _kernelTestHelper = GetRequiredService <KernelTestHelper>(); }
public IndexModel(ILogger <IndexModel> logger, IBlockchainService blockchainService, IConfiguration configuration) { _logger = logger; _blockchainService = blockchainService; _configuration = configuration; }
internal static async Task <Block> GetBlockAtHeightAsync(this IBlockchainService blockchainService, long height) { return(await blockchainService.GetBlockByHeightInBestChainBranchAsync(height)); }
public SideChainInitializationDataProvider(IOptionsSnapshot <ChainOptions> chainOptions, IOptionsSnapshot <CrossChainConfigOptions> crossChainConfigOptions, IChainInitializationDataPlugin chainInitializationDataPlugin, IBlockchainService blockchainService) { _chainOptions = chainOptions.Value; _chainInitializationDataPlugin = chainInitializationDataPlugin; _blockchainService = blockchainService; ParentChainId = ChainHelper.ConvertBase58ToChainId(crossChainConfigOptions.Value.ParentChainId); }