OSDN Git Service

fix https://github.com/Bytom/vapor/pull/374#discussion_r310125314
authorHAOYUatHZ <haoyu@protonmail.com>
Sun, 4 Aug 2019 23:50:53 +0000 (07:50 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Sun, 4 Aug 2019 23:50:53 +0000 (07:50 +0800)
docs/precog/README.md
docs/precog/config_example.json
docs/precog/sql_dump/precog_shema.sql
toolbar/precog/config/config.go
toolbar/precog/database/orm/chain.go [deleted file]
toolbar/precog/database/orm/node.go
toolbar/precog/monitor/monitor.go

index a6f31f9..5ffb4da 100644 (file)
@@ -16,19 +16,6 @@ Keep monitoring (leader & candidate) consensus nodes status in vapor network.
 
 ### /chain-status
 
-__method:__ POST
-
-__example response:__
-```
-{
-    "best_height": 1024,
-    "policy": {
-        "confirmations": 150,
-        "required_lantency_ms": 500
-    } 
-}
-```
-
 ### /list-nodes
 
 __method:__ POST
@@ -39,7 +26,7 @@ __example response:__
     [
         {
             "alias": "cobo",
-            "pubkey": "b928e46bb01e834fdf167185e31b15de7cc257af8bbdf17f9c7fefd5bb97b306d048b6bc0da2097152c1c2ff38333c756a543adbba7030a447dcc776b8ac64ef",
+            "public_key": "b928e46bb01e834fdf167185e31b15de7cc257af8bbdf17f9c7fefd5bb97b306d048b6bc0da2097152c1c2ff38333c756a543adbba7030a447dcc776b8ac64ef",
             "host": "vapornode.cobo.com",
             "port": 123,
             "best_height": 1023,
@@ -49,7 +36,7 @@ __example response:__
         },
         {
             "alias": "matpool",
-            "pubkey": "0f8669abbd3cc0a167156188e428f940088d5b2f36bb3449df71d2bdc5e077814ea3f68628eef279ed435f51ee26cff00f8bd28fabfd500bedb2a9e369f5c825",
+            "public_key": "0f8669abbd3cc0a167156188e428f940088d5b2f36bb3449df71d2bdc5e077814ea3f68628eef279ed435f51ee26cff00f8bd28fabfd500bedb2a9e369f5c825",
             "host": "vapornode.matpool.io",
             "port": 321,
             "best_height": 1024,
@@ -62,3 +49,4 @@ __example response:__
 ```
 
 
+### /get-node-statistics
\ No newline at end of file
index 980124f..8b2ed94 100644 (file)
@@ -13,7 +13,7 @@
     "bootstrap_nodes" : [
         {
             "alias" : "matpool",
-            "pubkey" : "0f8669abbd3cc0a167156188e428f940088d5b2f36bb3449df71d2bdc5e077814ea3f68628eef279ed435f51ee26cff00f8bd28fabfd500bedb2a9e369f5c825",
+            "public_key" : "0f8669abbd3cc0a167156188e428f940088d5b2f36bb3449df71d2bdc5e077814ea3f68628eef279ed435f51ee26cff00f8bd28fabfd500bedb2a9e369f5c825",
             "host": "vapornode.matpool.io",
             "port": 321,
         }
index ba2c4e8..25b3f25 100644 (file)
@@ -12,28 +12,13 @@ CREATE SCHEMA `precog`;
 
 USE `precog`;
 
-# Dump of table chains
-# ------------------------------------------------------------
-
-CREATE TABLE `chains` (
-  `id` tinyint(1) NOT NULL AUTO_INCREMENT,
-  `best_height` 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`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-LOCK TABLES `chains` WRITE;
-UNLOCK TABLES;
-
-
 # Dump of table nodes
 # ------------------------------------------------------------
 
 CREATE TABLE `nodes` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `alias` varchar(128) NOT NULL DEFAULT '',
-  `pub_key` char(128) NOT NULL DEFAULT '',
+  `public_key` char(128) NOT NULL DEFAULT '',
   `host` varchar(128) NOT NULL DEFAULT '',
   `port` smallint unsigned NOT NULL DEFAULT '0',
   `best_height` int(11) DEFAULT '0',
@@ -43,7 +28,7 @@ CREATE TABLE `nodes` (
   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   PRIMARY KEY (`id`),
-  UNIQUE KEY `pub_key` (`pub_key`),
+  UNIQUE KEY `public_key` (`public_key`),
   UNIQUE KEY `host_port` (`host`,`port`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
index 408a391..09d03be 100644 (file)
@@ -47,10 +47,10 @@ type Policy struct {
 }
 
 type Node struct {
-       Alias  string       `json:"alias"`
-       PubKey chainkd.XPub `json:"pubkey"`
-       Host   string       `json:"host"`
-       Port   uint16       `json:"port"`
+       Alias     string       `json:"alias"`
+       PublicKey chainkd.XPub `json:"public_key"`
+       Host      string       `json:"host"`
+       Port      uint16       `json:"port"`
 }
 
 type API struct {
diff --git a/toolbar/precog/database/orm/chain.go b/toolbar/precog/database/orm/chain.go
deleted file mode 100644 (file)
index 284795f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package orm
-
-import (
-       "time"
-)
-
-type Chain struct {
-       BestHeight uint64
-       CreatedAt  time.Time
-       UpdatedAt  time.Time
-}
index a470f26..892c592 100644 (file)
@@ -10,7 +10,7 @@ import (
 
 type Node struct {
        Alias           string
-       PubKey          string
+       PublicKey       string
        Host            string
        Port            uint16
        BestHeight      uint64
@@ -33,7 +33,7 @@ func (n *Node) MarshalJSON() ([]byte, error) {
 
        return json.Marshal(&struct {
                Alias         string `json:"alias"`
-               PubKey        string `json:"pubkey"`
+               PublicKey     string `json:"public_key"`
                Host          string `json:"host"`
                Port          uint16 `json:"port"`
                BestHeight    uint64 `json:"best_height"`
@@ -42,7 +42,7 @@ func (n *Node) MarshalJSON() ([]byte, error) {
                Status        string `json:"status"`
        }{
                Alias:         n.Alias,
-               PubKey:        n.PubKey,
+               PublicKey:     n.PublicKey,
                Host:          n.Host,
                Port:          n.Port,
                BestHeight:    n.BestHeight,
index 57a812d..3609f88 100644 (file)
@@ -36,14 +36,14 @@ func (m *monitor) Run() {
 func (m *monitor) updateBootstrapNodes() {
        for _, node := range m.cfg.Nodes {
                ormNode := &orm.Node{
-                       PubKey:          node.PubKey.String(),
+                       PublicKey:       node.PublicKey.String(),
                        Alias:           node.Alias,
                        Host:            node.Host,
                        Port:            node.Port,
                        ActiveBeginTime: time.Now(),
                }
 
-               if err := m.db.Where(&orm.Node{PubKey: ormNode.PubKey}).
+               if err := m.db.Where(&orm.Node{PublicKey: ormNode.PublicKey}).
                        Assign(&orm.Node{
                                Alias: node.Alias,
                                Host:  node.Host,