public PendingTransactionStreamProvider( IObservable <Unit> poller, IEthApiFilterService filterService, IEthApiTransactionsService transactionsService) { _poller = poller; _filterService = filterService; _transactionsService = transactionsService; }
public static async Task SendTransactionAsync( this IEthApiTransactionsService service, string signedTransactionData, string transactionHash, CancellationToken cancellationToken = default(CancellationToken)) { var transaction = await service.GetTransactionByHash.SendRequestAsync(transactionHash); // If transaction is not null, the transaction has already been broadcasted // and it is not necessary to broadcast it again. if (transaction != null) { return; } // Broadcasting transaction try { await service.SendRawTransaction.SendRequestAsync(signedTransactionData); } // Unfortunately, there are neither specific error code, nor specific properties for this case in an exception catch (RpcResponseException e) when(e.RpcError.Message == $"known transaction: {transactionHash}") { return; } // ...and waiting, until it appears on a blockchain node. transaction = await service.GetTransactionByHash.SendRequestAsync(transactionHash); var getTransactionCounter = 1; while (transaction == null) { // checking if it is time to re-push transaction if (getTransactionCounter == GetRetriesBeforePushAgain) { try { await service.SendRawTransaction.SendRequestAsync(signedTransactionData); } catch (RpcResponseException e) when(e.RpcError.Message == $"known transaction: {transactionHash}") { return; } getTransactionCounter = 0; } await Task.Delay(GetTransactionPollPeriodInMilliseconds, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); transaction = await service.GetTransactionByHash.SendRequestAsync(transactionHash); getTransactionCounter++; } }
public static async Task <string> SendTransactionAsync( this IEthApiTransactionsService service, string signedTransactionData, CancellationToken cancellationToken = default(CancellationToken)) { var transactionHash = Sha3Keccack.Current.CalculateHashFromHex(signedTransactionData); var transactionHashWithPrefix = $"0x{transactionHash}"; var transaction = await service.GetTransactionByHash.SendRequestAsync(transactionHashWithPrefix); // If transaction is not null, the transaction has already been broadcasted // and it is not necessary to broadcast it again. if (transaction != null) { return(transactionHashWithPrefix); } // Broadcasting transaction try { await service.SendRawTransaction.SendRequestAsync(signedTransactionData); } // Unfortunately, there are neither specific error code, nor specific properties for this case in an exception catch (RpcResponseException e) when(e.RpcError.Message == $"known transaction: {transactionHash}") { return(transactionHashWithPrefix); } // ...and waiting, until it appears on a blockchain node. transaction = await service.GetTransactionByHash.SendRequestAsync(transactionHashWithPrefix); while (transaction == null) { await Task.Delay(100, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); transaction = await service.GetTransactionByHash.SendRequestAsync(transactionHashWithPrefix); } return(transactionHashWithPrefix); }
public OperationsService( IEthApiTransactionsService ethereumApi, IQuorumTransactionSignerClient transactionSigner, IOperationsRepository operationsRepository, INoncesRepository noncesRepository, ITransactionRunner transactionRunner, long gasLimit, long gasPrice, ILogFactory logFactory) { _ethereumApi = ethereumApi; _transactionSigner = transactionSigner; _operationsRepository = operationsRepository; _noncesRepository = noncesRepository; _transactionRunner = transactionRunner; _gasLimit = gasLimit; _gasPrice = gasPrice; _log = logFactory.CreateLog(this); }
public static async Task <IReadOnlyCollection <Transaction> > GetTransactionsAsync( this IEthApiTransactionsService transactions, IEnumerable <string> hashes, int batchSize = 8) { var result = new List <Transaction>(); foreach (var batchOfHashes in hashes.Batch(batchSize)) { var batchOfTransactions = await Task.WhenAll ( batchOfHashes.Select(x => transactions.GetTransactionByHash.SendRequestAsync(x)) ); result.AddRange(batchOfTransactions); } return(result); }
public TransactionProcessor( IWeb3 web3, IContractTransactionProcessor contractTransactionProcessor, IValueTransactionProcessor valueTransactionProcessor, IContractCreationTransactionProcessor contractCreationTransactionProcessor, ITransactionLogProcessor transactionLogProcessor, IEnumerable <ITransactionFilter> transactionFilters = null, IEnumerable <ITransactionReceiptFilter> transactionReceiptFilters = null, IEnumerable <ITransactionAndReceiptFilter> transactionAndReceiptFilters = null) { TransactionProxy = web3.Eth.Transactions; ContractTransactionProcessor = contractTransactionProcessor; _valueTransactionProcessor = valueTransactionProcessor; _contractCreationTransactionProcessor = contractCreationTransactionProcessor; _transactionLogProcessor = transactionLogProcessor; _transactionFilters = new List <ITransactionFilter>( transactionFilters ?? new ITransactionFilter[0]); _transactionReceiptFilters = new List <ITransactionReceiptFilter>( transactionReceiptFilters ?? new ITransactionReceiptFilter[0]); _transactionAndReceiptFilters = new List <ITransactionAndReceiptFilter>( transactionAndReceiptFilters ?? new ITransactionAndReceiptFilter[0]); }
public EthGetContractTransactionErrorReason(IEthApiTransactionsService apiTransactionsService) { _apiTransactionsService = apiTransactionsService; }