示例#1
0
        private void ConvertThroughProto(LedgerOffset source)
        {
            Com.DigitalAsset.Ledger.Api.V1.LedgerOffset protoValue = source.ToProto();
            LedgerOffset target = LedgerOffset.FromProto(protoValue);

            Assert.IsTrue(source == target);
        }
示例#2
0
        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>();
        }
示例#4
0
 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());
 }
示例#7
0
 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);
             }
         }
     }
 }
示例#8
0
 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);
         }
     }
 }
示例#9
0
 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);
             }
         }
     }
 }
示例#10
0
        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);
        }
示例#11
0
        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()}");
                    }
                }
            }
        }
示例#12
0
        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);
        }
示例#13
0
 public IEnumerable <CompletionStreamResponse> CompletionStreamSync(string applicationId, LedgerOffset offset, IEnumerable <string> parties, string accessToken = null)
 {
     return(CompletionStreamImpl(applicationId, offset, parties, accessToken).ToListAsync().Result);
 }
示例#14
0
 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);
        }