Exemplo n.º 1
0
        public void RecordPoolSize(string chainId, DateTime time, ulong poolSize)
        {
            var fields = new Dictionary <string, object> {
                { "size", poolSize }
            };

            InfluxDBHelper.Set(chainId, "transaction_pool_size", fields, null, time);
        }
Exemplo n.º 2
0
        public void RecordPoolState(string chainId, DateTime time, int requestPoolSize, int receivePoolSize)
        {
            var fields = new Dictionary <string, object> {
                { "request", requestPoolSize }, { "receive", receivePoolSize }
            };

            InfluxDBHelper.Set(chainId, "network_pool_state", fields, null, time);
        }
Exemplo n.º 3
0
        public void RecordPoolState(string chainId, DateTime time, bool isAlive, bool isForked)
        {
            var fields = new Dictionary <string, object> {
                { "alive", isAlive }, { "forked", isForked }
            };

            InfluxDBHelper.Set(chainId, "node_state", fields, null, time);
        }
Exemplo n.º 4
0
        public async Task RecordRollBackTimes(string chainId, DateTime time)
        {
            var times = await GetRollBackTimes(chainId);

            var fields = new Dictionary <string, object> {
                { "times", times }
            };

            InfluxDBHelper.Set(chainId, "chain_rollback", fields, null, time);
        }
Exemplo n.º 5
0
        public async Task RecordInvalidBlockCount(string chainId, DateTime time)
        {
            var count = await GetInvalidBlockCount(chainId);

            var fields = new Dictionary <string, object> {
                { "count", count }
            };

            InfluxDBHelper.Set(chainId, "block_invalid", fields, null, time);
        }
Exemplo n.º 6
0
        public async Task RecordPoolSize(string chainId, DateTime time)
        {
            var poolSize = await GetPoolSize(chainId);

            var fields = new Dictionary <string, object> {
                { "size", poolSize }
            };

            InfluxDBHelper.Set(chainId, "transaction_pool_size", fields, null, time);
        }
Exemplo n.º 7
0
        public async Task RecordPoolState(string chainId, DateTime time)
        {
            var isAlive = await IsAlive(chainId);

            var isForked = await IsForked(chainId);

            var fields = new Dictionary <string, object> {
                { "alive", isAlive }, { "forked", isForked }
            };

            InfluxDBHelper.Set(chainId, "node_state", fields, null, time);
        }
Exemplo n.º 8
0
        //[Fact]
        public void TestSetAndGet()
        {
            var database = "unittest";

            InfluxDBHelper.CreateDatabase(database);

            var used = 50;
            var time = DateTime.Now;

            InfluxDBHelper.Set(database, "cpu", new Dictionary <string, object> {
                { "used", used }
            }, null, time);
            Thread.Sleep(1000);
            var result = InfluxDBHelper.Get(database, "select * from cpu");

            Assert.True(Convert.ToInt32(result[0].Values[0][1]) == used);

            InfluxDBHelper.DropDatabase(database);
        }
Exemplo n.º 9
0
        public async Task RecordBlockInfo(string chainId)
        {
            ulong currentHeight;
            var   currentRecord = InfluxDBHelper.Get(chainId, "select last(height) from block_info");

            if (currentRecord.Count == 0)
            {
                currentHeight = await GetCurrentChainHeight(chainId);
            }
            else
            {
                var record = currentRecord.First().Values.First();
                var time   = Convert.ToDateTime(record[0]);

                if (time < DateTime.Now.AddHours(-1))
                {
                    currentHeight = await GetCurrentChainHeight(chainId);
                }
                else
                {
                    currentHeight = Convert.ToUInt64(record[1]) + 1;
                }
            }

            var blockInfo = await GetBlockInfo(chainId, currentHeight);

            while (blockInfo.Result != null && blockInfo.Result.Body != null && blockInfo.Result.Header != null)
            {
                var fields = new Dictionary <string, object> {
                    { "height", currentHeight }, { "tx_count", blockInfo.Result.Body.TransactionsCount }
                };
                InfluxDBHelper.Set(chainId, "block_info", fields, null, blockInfo.Result.Header.Time);

                Thread.Sleep(1000);

                currentHeight++;
                blockInfo = await GetBlockInfo(chainId, currentHeight);
            }
        }