OSDN Git Service

add
authorHAOYUatHZ <haoyu@protonmail.com>
Fri, 2 Aug 2019 11:00:45 +0000 (19:00 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Fri, 2 Aug 2019 11:00:45 +0000 (19:00 +0800)
docs/precog/sql_dump/precog_shema.sql
toolbar/precog/database/orm/node.go

index 4c6b7e3..8237891 100644 (file)
@@ -34,14 +34,16 @@ CREATE TABLE `nodes` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `alias` varchar(128) NOT NULL DEFAULT '',
   `pub_key` char(128) NOT NULL DEFAULT '',
-  `host_port` varchar(128) NOT NULL DEFAULT '',
+  `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,
   `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`),
-  UNIQUE KEY `pub_key` (`pub_key`)
+  UNIQUE KEY `pub_key` (`pub_key`),
+  UNIQUE KEY `host_port` (`host`,`port`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 LOCK TABLES `nodes` WRITE;
index 631f8ec..f80716b 100644 (file)
@@ -10,7 +10,8 @@ import (
 type Node struct {
        Alias      string        `json:"alias"`
        PubKey     chainkd.XPub  `json:"pubkey"`
-       HostPort   string        `json:"host_port"`
+       Host       string        `json:"host"`
+       Port       uint16        `json:"port"`
        BestHeight uint64        `json:"best_height"`
        LantencyMS sql.NullInt64 `json:"lantency_ms"`
        Status     uint8         `json:"status"`