OSDN Git Service

add
authorHAOYUatHZ <haoyu@protonmail.com>
Fri, 2 Aug 2019 11:43:30 +0000 (19:43 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Fri, 2 Aug 2019 11:43:30 +0000 (19:43 +0800)
docs/precog/README.md
toolbar/precog/config/config.go
toolbar/precog/database/orm/node.go

index 923f1c9..18ccd39 100644 (file)
@@ -24,7 +24,7 @@ __example response:__
     "best_height": 1024,
     "policy": {
         "confirmations": 150,
-        "lantency_ms": 500
+        "required_lantency_ms": 500
     } 
 }
 ```
@@ -40,16 +40,22 @@ __example response:__
         {
             "alias": "cobo",
             "pubkey": "...",
+            "host": "vapornode.cobo.com",
+            "port": 123,
             "best_height": 1023,
             "lantency_ms": 300,
-            "active_minutes": 4096
+            "active_minutes": 4096,
+            "status": "healthy"
         },
         {
             "alias": "matpool",
             "pubkey": "...",
+            "host": "vapornode.matpool.io",
+            "port": 321,
             "best_height": 1024,
             "lantency_ms": 299,
-            "active_minutes": 4097
+            "active_minutes": 4097,
+            "status": "healthy"
         }
     ] 
 }
index 2113e95..408a391 100644 (file)
@@ -35,24 +35,26 @@ func NewConfigWithPath(path string) *Config {
 
 type Config struct {
        MySQLConfig      common.MySQLConfig `json:"mysql"`
-       CheckFreqSeconds uint64             `json:"check_seconds"`
+       CheckFreqSeconds uint64             `json:"check_frequency_seconds"`
        Policy           Policy             `json:"policy"`
        Nodes            []Node             `json:"bootstrap_nodes"`
        API              API                `json:"api"`
 }
 
 type Policy struct {
-       LantencyMS uint64 `json:"lantency_ms"`
+       Confirmations      uint64 `json:"confirmations"`
+       RequiredLantencyMS uint64 `json:"required_lantency_ms"`
 }
 
 type Node struct {
-       Alias    string       `json:"alias"`
-       HostPort string       `json:"host_port"`
-       PubKey   chainkd.XPub `json:"pubkey"`
+       Alias  string       `json:"alias"`
+       PubKey chainkd.XPub `json:"pubkey"`
+       Host   string       `json:"host"`
+       Port   uint16       `json:"port"`
 }
 
 type API struct {
-       HostPort      bool   `json:"host_port"`
+       ListeningPort bool   `json:"listening_port"`
        AccessToken   string `json:"access_token"`
        IsReleaseMode bool   `json:"is_release_mode"`
 }
index 4e1de5f..7e29c59 100644 (file)
@@ -24,29 +24,29 @@ type Node struct {
 func (n *Node) MarshalJSON() ([]byte, error) {
        status := common.StatusMap[n.Status]
        var lantency uint64
-       var activeTime time.Duration
+       var activeMinutes uint64
        if n.Status != common.NodeOfflineStatus {
                lantency = n.LantencyMS
-               activeTime = time.Since(n.ActiveBeginTime)
+               activeMinutes = uint64(time.Since(n.ActiveBeginTime).Minutes())
        }
 
        return json.Marshal(&struct {
-               Alias      string        `json:"alias"`
-               PubKey     chainkd.XPub  `json:"pubkey"`
-               Host       string        `json:"host"`
-               Port       uint16        `json:"port"`
-               BestHeight uint64        `json:"best_height"`
-               LantencyMS uint64        `json:"lantency_ms,omitempty"`
-               ActiveTime time.Duration `json:"active_time,omitempty"`
-               Status     string        `json:"status"`
+               Alias         string       `json:"alias"`
+               PubKey        chainkd.XPub `json:"pubkey"`
+               Host          string       `json:"host"`
+               Port          uint16       `json:"port"`
+               BestHeight    uint64       `json:"best_height"`
+               LantencyMS    uint64       `json:"lantency_ms,omitempty"`
+               ActiveMinutes uint64       `json:"active_minutes,omitempty"`
+               Status        string       `json:"status"`
        }{
-               Alias:      n.Alias,
-               PubKey:     n.PubKey,
-               Host:       n.Host,
-               Port:       n.Port,
-               BestHeight: n.BestHeight,
-               LantencyMS: lantency,
-               activeTime: activeTime,
-               Status:     status,
+               Alias:         n.Alias,
+               PubKey:        n.PubKey,
+               Host:          n.Host,
+               Port:          n.Port,
+               BestHeight:    n.BestHeight,
+               LantencyMS:    lantency,
+               ActiveMinutes: activeMinutes,
+               Status:        status,
        })
 }