OSDN Git Service

clean up
authorHAOYUatHZ <haoyu@protonmail.com>
Mon, 19 Aug 2019 01:38:48 +0000 (09:38 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Mon, 19 Aug 2019 01:38:48 +0000 (09:38 +0800)
docs/precog/config_example.json
toolbar/precog/config/config.go
toolbar/precog/monitor/monitor.go

index 6528cfe..76406ff 100644 (file)
@@ -11,7 +11,7 @@
         "log_mode" : true
     },
     "check_frequency_seconds" : 60,
-    "bootstrap_nodes" : [
+    "seeds" : [
         {
             "alias" : "seed1",
             "xpub" : "f2767279cd01ed8793808e0542a18958e1a2f3a6b6fe5328ec79596a022bc6f085951a98a631917563f86bb91db9159dd2969ff9d690fc12b250baff2b6f6a1d",
index 6dc69b6..2647440 100644 (file)
@@ -38,7 +38,7 @@ type Config struct {
        MySQLConfig      common.MySQLConfig `json:"mysql"`
        CheckFreqSeconds uint64             `json:"check_frequency_seconds"`
        Policy           Policy             `json:"policy"`
-       Nodes            []Node             `json:"bootstrap_nodes"`
+       Nodes            []Node             `json:"seeds"`
        API              API                `json:"api"`
 }
 
index 5fb0726..da4ad9b 100644 (file)
@@ -28,14 +28,16 @@ import (
 )
 
 type monitor struct {
-       cfg     *config.Config
-       db      *gorm.DB
-       nodeCfg *vaporCfg.Config
-       sw      *p2p.Switch
-       discvCh chan *dht.Node
-       privKey chainkd.XPrv
-       chain   *mock.Chain
-       txPool  *mock.Mempool
+       cfg               *config.Config
+       db                *gorm.DB
+       nodeCfg           *vaporCfg.Config
+       sw                *p2p.Switch
+       discvCh           chan *dht.Node
+       privKey           chainkd.XPrv
+       chain             *mock.Chain
+       txPool            *mock.Mempool
+       tryConnectStartCh chan struct{}
+       tryConnectEndCh   chan struct{}
 }
 
 // TODO: set myself as SPV?
@@ -67,13 +69,15 @@ func NewMonitor(cfg *config.Config, db *gorm.DB) *monitor {
        }
 
        return &monitor{
-               cfg:     cfg,
-               db:      db,
-               nodeCfg: nodeCfg,
-               discvCh: discvCh,
-               privKey: privKey.(chainkd.XPrv),
-               chain:   chain,
-               txPool:  txPool,
+               cfg:               cfg,
+               db:                db,
+               nodeCfg:           nodeCfg,
+               discvCh:           discvCh,
+               privKey:           privKey.(chainkd.XPrv),
+               chain:             chain,
+               txPool:            txPool,
+               tryConnectStartCh: make(chan struct{}, 1),
+               tryConnectEndCh:   make(chan struct{}, 1),
        }
 }