private void ConvertThroughProto(LedgerOffset source) { Com.DigitalAsset.Ledger.Api.V1.LedgerOffset protoValue = source.ToProto(); LedgerOffset target = LedgerOffset.FromProto(protoValue); Assert.IsTrue(source == target); }
public void ProtoConversionOfLedgerBoundaryAbsolutesResolvesToledgerBoundaries() { var offsetBegin = LedgerOffset.FromProto(new LedgerOffset.Absolute(LedgerOffset.LedgerBegin.Instance.Offset).ToProto()); Assert.AreEqual(typeof(LedgerOffset.LedgerBegin), offsetBegin.GetType()); var offsetEnd = LedgerOffset.FromProto(new LedgerOffset.Absolute(LedgerOffset.LedgerEnd.Instance.Offset).ToProto()); Assert.AreEqual(typeof(LedgerOffset.LedgerEnd), offsetEnd.GetType()); }
public void ProtoConversionOfLedgerBoundaryAbsolutesResolvesToledgerBoundaries() { var offsetBegin = LedgerOffset.FromProto(new LedgerOffset.Absolute(LedgerOffset.LedgerBegin.Instance.Offset).ToProto()); offsetBegin.Should().BeOfType <LedgerOffset.LedgerBegin>(); var offsetEnd = LedgerOffset.FromProto(new LedgerOffset.Absolute(LedgerOffset.LedgerEnd.Instance.Offset).ToProto()); offsetEnd.Should().BeOfType <LedgerOffset.LedgerEnd>(); }
public IObservable <GetTransactionTreesResponse> GetTransactionTrees( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, Optional <string> accessToken = null, TraceContext traceContext = null) { return(_transactionsClient.GetTransactionTrees(transactionFilter, beginOffset, endOffset, verbose, accessToken?.Reduce((string)null), traceContext).CreateAsyncObservable(_scheduler)); }
public IEnumerable <GetTransactionTreesResponse> GetTransactionTreesSync( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, string accessToken = null, TraceContext traceContext = null) { return(GetTransactionTreesImpl(transactionFilter, beginOffset, endOffset, verbose, accessToken, traceContext).ToListAsync().Result); }
public IAsyncEnumerator <GetTransactionTreesResponse> GetTransactionTrees( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, string accessToken = null, TraceContext traceContext = null) { return(GetTransactionTreesImpl(transactionFilter, beginOffset, endOffset, verbose, accessToken, traceContext).ReadAllAsync().GetAsyncEnumerator()); }
public async Task Run(TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset, bool verbose, string accessToken = null, TraceContext traceContext = null) { await using (var stream = _transactionsClient.GetTransactions(transactionFilter, beginOffset, endOffset, verbose, accessToken, traceContext)) { while (await stream.MoveNextAsync()) { foreach (var tx in stream.Current.Transactions) { _state = _update(_state, tx); var commands = _handler(_state); await _commandClient.SubmitAndWaitAsync(commands); } } } }
public IEnumerable <GetTransactionTreesResponse> GetTransactionTreesSync( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, string accessToken = null, TraceContext traceContext = null) { using (var stream = GetTransactionTrees(transactionFilter, beginOffset, endOffset, verbose, accessToken, traceContext)) { while (stream.MoveNext().Result) { yield return(stream.Current); } } }
public async Task Run( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, string accessToken = null, TraceContext traceContext = null) { using (var stream = _transactionClient.GetTransactions(transactionFilter, beginOffset, endOffset, verbose, accessToken, traceContext)) { while (stream.MoveNext().Result) { foreach (var tx in stream.Current.Transactions) { var commands = _handler(tx); await _commandClient.SubmitAndWaitAsync(commands); } } } }
public IAsyncEnumerator <GetTransactionTreesResponse> GetTransactionTrees( TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset = null, bool verbose = true, string accessToken = null, TraceContext traceContext = null) { var request = new GetTransactionsRequest { LedgerId = LedgerId, Filter = transactionFilter, Begin = beginOffset, End = endOffset, Verbose = verbose, TraceContext = traceContext }; var response = _transactionsClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.GetTransactionTrees(r, co)); return(response.ResponseStream); }
private async Task PrintTransactions(string party) { var transactionFilter = new TransactionFilter(); transactionFilter.FiltersByParty.Add(party, new Filters()); var beginOffset = new LedgerOffset { Boundary = LedgerBoundary.LedgerBegin }; var endOffset = new LedgerOffset { Boundary = LedgerBoundary.LedgerEnd }; await using (var stream = _clients.TransactionsClient.GetTransactions(transactionFilter, beginOffset, endOffset)) { while (await stream.MoveNextAsync()) { foreach (var tx in stream.Current.Transactions) { Console.WriteLine($"Transaction: {tx.ToString()}"); } } } }
private IAsyncStreamReader <CompletionStreamResponse> CompletionStreamImpl(string applicationId, LedgerOffset offset, IEnumerable <string> parties, string accessToken) { var request = new CompletionStreamRequest { LedgerId = LedgerId, ApplicationId = applicationId }; if (offset != null) { request.Offset = offset; } request.Parties.AddRange(parties); var response = _commandCompletionClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.CompletionStream(r, co)); return(response.ResponseStream); }
public IEnumerable <CompletionStreamResponse> CompletionStreamSync(string applicationId, LedgerOffset offset, IEnumerable <string> parties, string accessToken = null) { return(CompletionStreamImpl(applicationId, offset, parties, accessToken).ToListAsync().Result); }
public IAsyncEnumerator <CompletionStreamResponse> CompletionStream(string applicationId, LedgerOffset offset, IEnumerable <string> parties, string accessToken = null) { return(CompletionStreamImpl(applicationId, offset, parties, accessToken).ReadAllAsync().GetAsyncEnumerator()); }
public IEnumerable <CompletionStreamResponse> CompletionStreamSync(string applicationId, LedgerOffset offset, IEnumerable <string> parties, string accessToken = null) { using (var stream = CompletionStream(applicationId, offset, parties, accessToken)) { while (stream.MoveNext().Result) { yield return(stream.Current); } } }
private IAsyncStreamReader <GetTransactionsResponse> GetTransactionsImpl(TransactionFilter transactionFilter, LedgerOffset beginOffset, LedgerOffset endOffset, bool verbose, string accessToken, TraceContext traceContext) { var request = new GetTransactionsRequest { LedgerId = LedgerId, Filter = transactionFilter, Begin = beginOffset, End = endOffset, Verbose = verbose, TraceContext = traceContext }; var response = _transactionsClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.GetTransactions(r, co)); return(response.ResponseStream); }