public TransactionInfo TransactionInfo(string id)
 {
     using (var client = CreateApi())
     {
         var ids  = id.Split('.');
         var trId = new TransactionId()
         {
             Index    = int.Parse(ids[1]) - 1,
             PoolHash = ConvUtils.ConvertHashBack(ids[0])
         };
         var tr    = client.TransactionGet(trId);
         var tInfo = new TransactionInfo(0, null, tr.Transaction.Trxn)
         {
             Id = id, Found = tr.Found
         };
         if (!tr.Found)
         {
             return(tInfo);
         }
         if (string.IsNullOrEmpty(tInfo.PoolHash))
         {
             return(tInfo);
         }
         var pool = client.PoolInfoGet(ConvUtils.ConvertHashBack(tInfo.PoolHash), 0);
         tInfo.Time = ConvUtils.UnixTimeStampToDateTime(pool.Pool.Time);
         return(tInfo);
     }
 }
 public DateTime GetTransactionTime(string id)
 {
     using (var client = CreateApi())
     {
         var poolHash = id.Split(".")[0];
         var pool     = client.PoolInfoGet(ConvUtils.ConvertHashBack(poolHash), 0);
         return(ConvUtils.UnixTimeStampToDateTime(pool.Pool.Time));
     }
 }
示例#3
0
        // Gets transaction time by transaction id
        public DateTime GetTransactionTime(string id)
        {
            using (var client = CreateApi())
            {
                // Extract block hash from transaction id
                var poolHash = id.Split(".")[0];

                // Get block data from API
                var pool = client.PoolInfoGet(ConvUtils.ConvertHashBack(poolHash), 0);

                // Return block time - this is also a transaction time
                return(ConvUtils.UnixTimeStampToDateTime(pool.Pool.Time));
            }
        }
示例#4
0
        private static Point[] GetPoints(NodeApi.API.ISync client, int poolsCount, out List <PoolInfo> lastPools)
        {
            var result = client.PoolListGet(0, poolsCount);

            lastPools = result.Pools.Take(100).Select(p => new PoolInfo(p)).ToList();
            const int interval   = 10; // seconds
            const int intervalMs = interval * 1000;

            return(result.Pools.GroupBy(pool => pool.Time / intervalMs)
                   .Select(g => new Point
            {
                X = ConvUtils.UnixTimeStampToDateTime(g.Key * intervalMs),
                Y = g.Sum(p => p.TransactionsCount) / interval
            }).OrderBy(p => p.X).ToArray());
        }
示例#5
0
        // Gets transaction data from API by given transaction id
        public TransactionInfo TransactionInfo(string id)
        {
            using (var client = CreateApi())
            {
                // Prepare transaction id for request
                var ids  = id.Split('.');
                var trId = new TransactionId()
                {
                    Index    = int.Parse(ids[1]) - 1,
                    PoolHash = ConvUtils.ConvertHashBack(ids[0])
                };

                // Get data from API
                var tr = client.TransactionGet(trId);

                // Prepare the result
                var tInfo = new TransactionInfo(0, null, tr.Transaction.Trxn)
                {
                    Id = id, Found = tr.Found
                };

                // if transaction was not found, return the result
                if (!tr.Found)
                {
                    return(tInfo);
                }

                // Otherwise, request block data and store block time in the result
                if (string.IsNullOrEmpty(tInfo.PoolHash))
                {
                    return(tInfo);
                }
                var pool = client.PoolInfoGet(ConvUtils.ConvertHashBack(tInfo.PoolHash), 0);
                tInfo.Time = ConvUtils.UnixTimeStampToDateTime(pool.Pool.Time);

                // return the result
                return(tInfo);
            }
        }
示例#6
0
 public TransactionInfo TransactionInfo(string id)
 {
     using (var client = CreateApi())
     {
         var ids   = id.Split('.');
         var tr    = client.TransactionGet($"{ids[0]}:{int.Parse(ids[1]) - 1}");
         var tInfo = new TransactionInfo(0, id, tr.Transaction)
         {
             Found = tr.Found
         };
         if (!tr.Found)
         {
             return(tInfo);
         }
         if (string.IsNullOrEmpty(tInfo.PoolHash))
         {
             return(tInfo);
         }
         var pool = client.PoolInfoGet(ConvUtils.ConvertHashBackAscii(tInfo.PoolHash), 0);
         tInfo.Age = ConvUtils.UnixTimeStampToDateTime(pool.Pool.Time).ToString("G");
         return(tInfo);
     }
 }