OSDN Git Service

fix schema
authorHAOYUatHZ <haoyu@protonmail.com>
Mon, 5 Aug 2019 08:05:19 +0000 (16:05 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Mon, 5 Aug 2019 08:05:19 +0000 (16:05 +0800)
docs/precog/README.md
docs/precog/sql_dump/precog_schema.sql [moved from docs/precog/sql_dump/precog_shema.sql with 64% similarity]
toolbar/precog/database/orm/node.go
toolbar/precog/database/orm/node_liveness.go

index 5ffb4da..06818fb 100644 (file)
@@ -4,18 +4,15 @@ Keep monitoring (leader & candidate) consensus nodes status in vapor network.
 
 ## Init
 
-### Database Scheme
-[federation_shema.sql](./sql_dump/federation_shema.sql)
+### Database Schema
+[federation_schema.sql](./sql_dump/federation_shema.sql)
 
 ### Config
 
 ## API
 
-+ [/chain-status](#chain-status)
 + [/list-nodes](#list-nodes)
 
-### /chain-status
-
 ### /list-nodes
 
 __method:__ POST
similarity index 64%
rename from docs/precog/sql_dump/precog_shema.sql
rename to docs/precog/sql_dump/precog_schema.sql
index 25b3f25..64bc852 100644 (file)
@@ -22,9 +22,7 @@ CREATE TABLE `nodes` (
   `host` varchar(128) NOT NULL DEFAULT '',
   `port` smallint unsigned NOT NULL DEFAULT '0',
   `best_height` int(11) DEFAULT '0',
-  `lantency_ms` int(11) DEFAULT NULL,
-  `active_begin_time` timestamp,
-  `status` tinyint(1) NOT NULL DEFAULT '0',
+  `latest_daily_uptime_minutes` int(11) DEFAULT '0',
   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   PRIMARY KEY (`id`),
@@ -35,3 +33,23 @@ CREATE TABLE `nodes` (
 LOCK TABLES `nodes` WRITE;
 UNLOCK TABLES;
 
+
+# Dump of table node_livenesses
+# ------------------------------------------------------------
+
+CREATE TABLE `node_livenesses` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `node_id` int(11) NOT NULL,
+  `ping_times` int(11) DEFAULT '0',
+  `pong_times` int(11) DEFAULT '0',
+  `avg_lantency_ms` int(11) DEFAULT NULL,
+  `status` tinyint(1) NOT NULL DEFAULT '0',
+  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  CONSTRAINT `node_livenesses_ibfk_1` FOREIGN KEY (`node_id`) REFERENCES `nodes` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+LOCK TABLES `node_livenesses` WRITE;
+UNLOCK TABLES;
+
index a5b60ac..20882d9 100644 (file)
@@ -5,11 +5,12 @@ import (
 )
 
 type Node struct {
-       Alias      string
-       PublicKey  string
-       Host       string
-       Port       uint16
-       BestHeight uint64
-       CreatedAt  time.Time
-       UpdatedAt  time.Time
+       Alias                    string
+       PublicKey                string
+       Host                     string
+       Port                     uint16
+       BestHeight               uint64
+       LatestDailyUptimeMinutes uint64
+       CreatedAt                time.Time
+       UpdatedAt                time.Time
 }
index 7ba45eb..f6fd4e0 100644 (file)
@@ -7,8 +7,8 @@ import (
 
 type NodeLiveness struct {
        NodeID        uint16
-       ProbeTimes    uint64
-       ResponseTimes uint64
+       PingTimes     uint64
+       PongTimes     uint64
        AvgLantencyMS sql.NullInt64
        Status        uint8
        CreatedAt     time.Time