/// <summary> /// Send a transaction to the peer using the stream call. /// Note: this method is not thread safe. /// </summary> private async Task SendTransactionAsync(Transaction transaction) { if (_transactionStreamCall == null) { _transactionStreamCall = _client.TransactionBroadcastStream(new Metadata { { GrpcConstants.SessionIdMetadataKey, OutboundSessionId } }); } try { await _transactionStreamCall.RequestStream.WriteAsync(transaction); } catch (RpcException) { _transactionStreamCall.Dispose(); _transactionStreamCall = null; throw; } }
/// <summary> /// Send a transaction to the peer using the stream call. /// Note: this method is not thread safe. /// </summary> public async Task SendTransactionAsync(Transaction transaction) { if (!IsConnected) { return; } if (_transactionStreamCall == null) { _transactionStreamCall = _client.TransactionBroadcastStream(); } try { await _transactionStreamCall.RequestStream.WriteAsync(transaction); } catch (RpcException e) { _transactionStreamCall.Dispose(); _transactionStreamCall = null; HandleFailure(e, $"Error during transaction broadcast: {transaction.GetHash()}."); } }