Beispiel #1
0
        public IActionResult Index()
        {
            HashrateViewModel hashRate;
            var coins = mainCoins.GetCoin();

            if (!_cache.TryGetValue(coins.CoinSymbol + "_main_index", out hashRate))
            {
                var  lastBlock           = mainCoins.GetLastBlockMongo();
                var  coinconfirm         = lastBlock + coins.CoinConfirms;
                var  lastBlockWalletHash = mainCoins.GetBlockByIdMongo(lastBlock);
                int  showBlocks          = _configuration.GetSection("TotalShow").Get <int>();
                var  lastBlocks          = mainCoins.GetlastXAssetBlocks(showBlocks);
                var  blk      = lastBlocks.FirstOrDefault();
                uint blkAsset = 0;
                if (blk != null)
                {
                    blkAsset = checked ((uint)blk.Height);
                }
                hashRate = new HashrateViewModel
                {
                    ShowBlocks     = showBlocks,
                    LastBlock      = lastBlock,
                    LastAssetBlock = blkAsset,
                    LastBlocks     = lastBlocks,
                    MainCoinModel  = coins
                };
                _cache.Set(coins.CoinSymbol + "_main_index", hashRate, _memoryCacheEntryOptions);
            }
            return(View(hashRate));
        }
Beispiel #2
0
        public ActionResult GetRawTansaction(string txid)
        {
            bool exists;

            if (_cache.TryGetValue(_ip, out exists))
            {
                var strIPTimeout = "{ \"error\" : \"too much requests from your IP, put sleep 1 sec between requests\" }";
                return(Content(strIPTimeout, "application/json"));;
            }
            string str = string.Empty;

            try
            {
                var tx = mainCoins.GetRawAssetTransactionMongo(txid);
                if (tx != null)
                {
                    tx.confirmations = (int)mainCoins.GetLastBlockMongo() - tx.Height + 1;
                }
                if (tx == null)
                {
                    throw new Exception();
                }
                str = JsonConvert.SerializeObject(tx);
            }
            catch
            {
                str = "{ \"error\" : \"data error\" }";
            }
            _cache.Set(_ip, true, _memoryCacheEntryOptions);
            return(Content(str, "application/json"));
        }