Ejemplo n.º 1
0
        public TransactionsData PoolTransactions(string hash, int page, int txcount)
        {
            const int numPerPage = 50;

            if (page <= 0)
            {
                page = 1;
            }
            using (var client = CreateApi())
            {
                var lastPage = ConvUtils.GetNumPages(txcount, numPerPage);
                if (page > lastPage)
                {
                    page = lastPage;
                }
                var result = new TransactionsData
                {
                    Page         = page,
                    LastPage     = lastPage,
                    HaveNextPage = page < lastPage
                };
                var offset = numPerPage * (page - 1);
                var poolTr = client.PoolTransactionsGet(ConvUtils.ConvertHashBackAscii(hash), 0, offset, numPerPage);
                var i      = offset + 1;
                foreach (var t in poolTr.Transactions)
                {
                    var tInfo = new TransactionInfo(i, $"{hash}.{i}", t);
                    result.Transactions.Add(tInfo);
                    i++;
                }
                result.NumStr = poolTr.Transactions.Any() ? $"{offset + 1} - {offset+ poolTr.Transactions.Count} of {txcount}" : "0";
                return(result);
            }
        }
Ejemplo n.º 2
0
        public TransactionsData PoolTransactions(string hash, int page)
        {
            if (page <= 0)
            {
                page = 1;
            }
            using (var client = CreateApi())
            {
                var result = new TransactionsData {
                    Page = page
                };
                const int numPerPage = 50;
                var       offset     = numPerPage * (page - 1);
                var       poolTr     = client.PoolTransactionsGet(ConvUtils.ConvertHashBackAscii(hash), 0, offset, numPerPage);
                var       i          = offset + 1;
                foreach (var t in poolTr.Transactions)
                {
                    var tInfo = new TransactionInfo(i, $"{hash}.{i}", t);
                    result.Transactions.Add(tInfo);
                    i++;
                }

                return(result);
            }
        }
Ejemplo n.º 3
0
 public DateTime GetTransactionTime(string id)
 {
     using (var client = CreateApi())
     {
         var poolHash = id.Split(".")[0];
         var pool     = client.PoolInfoGet(ConvUtils.ConvertHashBackAscii(poolHash), 0);
         return(ConvUtils.UnixTimeStampToDateTime(pool.Pool.Time));
     }
 }
Ejemplo n.º 4
0
        public TransactionsData PoolData(string id)
        {
            using (var client = CreateApi())
            {
                var poolHash = ConvUtils.ConvertHashBackAscii(id);
                var pool     = client.PoolInfoGet(poolHash, 0);

                var result = new TransactionsData
                {
                    Page  = 1,
                    Found = pool.IsFound,
                    Info  = new PoolInfo(pool.Pool)
                };
                return(result);
            }
        }
Ejemplo n.º 5
0
 public string GetTransactionAge(string id)
 {
     using (var client = CreateApi())
     {
         if (!id.Contains("."))
         {
             return(string.Empty);
         }
         var poolHash = id.Split(".")[0];
         if (string.IsNullOrEmpty(poolHash))
         {
             return(string.Empty);
         }
         var pool = client.PoolInfoGet(ConvUtils.ConvertHashBackAscii(poolHash), 0);
         return(ConvUtils.GetAge(pool.Pool.Time));
     }
 }
Ejemplo n.º 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);
     }
 }