コード例 #1
0
ファイル: QuotesCache.cs プロジェクト: yepeek/tzkt
        public QuotesCache(StateCache state, IConfiguration config, ILogger <QuotesCache> logger) : base(config)
        {
            logger.LogDebug("Initializing quotes cache...");

            Quotes = new List <double> [6];
            State  = state;
            Logger = logger;

            var sql = @"
                SELECT    ""Btc"", ""Eur"", ""Usd"", ""Cny"", ""Jpy"", ""Krw""
                FROM      ""Quotes""
                ORDER BY  ""Level""";

            using var db = GetConnection();
            var rows = db.Query(sql);

            var cnt = rows.Count();

            for (int i = 0; i < Quotes.Length; i++)
            {
                Quotes[i] = new List <double>(cnt + 130_000);
            }

            foreach (var row in rows)
            {
                Quotes[0].Add(row.Btc);
                Quotes[1].Add(row.Eur);
                Quotes[2].Add(row.Usd);
                Quotes[3].Add(row.Cny);
                Quotes[4].Add(row.Jpy);
                Quotes[5].Add(row.Krw);
            }

            logger.LogInformation("Loaded {1} quotes", Quotes[0].Count);
        }
コード例 #2
0
        public ProtocolsCache(StateCache state, IConfiguration config, ILogger <ProtocolsCache> logger) : base(config)
        {
            logger.LogDebug("Initializing protocols cache...");

            State  = state;
            Logger = logger;

            using var db = GetConnection();
            Protocols    = db.Query <Protocol>(@"SELECT * FROM ""Protocols"" ORDER BY ""Code""").ToList();

            logger.LogInformation("Loaded {1} of {2} protocols", Protocols.Count, state.Current.ProtocolsCount);
        }
コード例 #3
0
ファイル: TimeCache.cs プロジェクト: yepeek/tzkt
        public TimeCache(StateCache state, ProtocolsCache protocols, IConfiguration config, ILogger <TimeCache> logger) : base(config)
        {
            logger.LogDebug("Initializing timestamps cache...");

            State     = state;
            Protocols = protocols;
            Logger    = logger;

            using var db = GetConnection();
            var times = db.Query <DateTime>(@"SELECT ""Timestamp"" FROM ""Blocks"" ORDER BY ""Level""");

            Times = new List <DateTime>(times.Count() + 130_000);
            Times.AddRange(times);

            logger.LogInformation("Loaded {1} timestamps", Times.Count);
        }