Beispiel #1
0
        public async Task <Header> GetHeaderAsync()
        {
            if (DateTime.UtcNow >= NextBlock)
            {
                var header = await Rpc.GetObjectAsync <Header>("chains/main/blocks/head/header");

                if (header.ChainId != ChainId)
                {
                    throw new Exception("Invalid chain");
                }

                if (header.Protocol != Header?.Protocol)
                {
                    Constants = await Rpc.GetObjectAsync <Constants>("chains/main/blocks/head/context/constants");
                }

                NextBlock = header.Level != Header?.Level
                    ? header.Timestamp.AddSeconds(Constants.BlockIntervals[0])
                    : DateTime.UtcNow.AddSeconds(1);

                Header = header;
            }

            return(Header);
        }
Beispiel #2
0
        async Task <List <CoingeckoQuote> > GetQuotes(string currency, DateTime from, DateTime to)
        {
            var _from = (long)(from - DateTime.UnixEpoch).TotalSeconds;
            var _to   = (long)(to - DateTime.UnixEpoch).TotalSeconds;

            return((await Client.GetObjectAsync <CoingeckoQuotes>(
                        $"coins/tezos/market_chart/range?vs_currency={currency}&from={_from}&to={_to}")).Prices);
        }