OSDN Git Service

clean
authorHAOYUatHZ <haoyu@protonmail.com>
Sat, 17 Aug 2019 06:49:28 +0000 (14:49 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Sat, 17 Aug 2019 06:49:28 +0000 (14:49 +0800)
docs/precog/README.md
toolbar/precog/monitor/crud.go
toolbar/precog/monitor/monitor.go

index 1df65e9..3423b69 100644 (file)
@@ -8,6 +8,10 @@ Keep monitoring (leader & candidate) consensus nodes status in vapor network.
 [precog_schema.sql](./sql_dump/precog_schema.sql)
 
 ### Config
+run with [config_example.json](docs/precog/config_example.json)
+```
+go run cmd/precog/main.go docs/precog/config_example.json
+```
 
 ## API
 
index d396806..7796736 100644 (file)
@@ -5,16 +5,11 @@ import (
 
        "github.com/jinzhu/gorm"
 
+       "github.com/vapor/netsync/peers"
        "github.com/vapor/toolbar/precog/config"
        "github.com/vapor/toolbar/precog/database/orm"
 )
 
-// TODO:
-// implement logic first, and then refactor
-// /home/gavin/work/go/src/github.com/vapor/
-// p2p/test_util.go
-// p2p/switch_test.go
-
 // TODO: get lantency
 // TODO: get best_height
 // TODO: decide check_height("best best_height" - "confirmations")
@@ -48,3 +43,7 @@ func (m *monitor) upSertNode(node *config.Node) error {
                        Port:  ormNode.Port,
                }).FirstOrCreate(ormNode).Error
 }
+
+func (m *monitor) savePeerInfo(peerInfo *peers.PeerInfo) error {
+       return nil
+}
index 47361bc..aca3d8c 100644 (file)
@@ -1,27 +1,22 @@
 package monitor
 
 import (
-       // "encoding/binary"
-       // "encoding/hex"
        "fmt"
        "io/ioutil"
        "os"
-       // "os/user"
        "strings"
        "time"
 
        "github.com/jinzhu/gorm"
        log "github.com/sirupsen/logrus"
-       // dbm "github.com/vapor/database/leveldb"
 
        vaporCfg "github.com/vapor/config"
        "github.com/vapor/crypto/ed25519/chainkd"
        dbm "github.com/vapor/database/leveldb"
        "github.com/vapor/event"
-       "github.com/vapor/p2p"
-       // conn "github.com/vapor/p2p/connection"
        "github.com/vapor/netsync/chainmgr"
        "github.com/vapor/netsync/consensusmgr"
+       "github.com/vapor/p2p"
        // msgs "github.com/vapor/netsync/messages"
        "github.com/vapor/netsync/peers"
        "github.com/vapor/p2p/discover/dht"
@@ -180,6 +175,8 @@ func (m *monitor) checkStatusRoutine() {
                        if peerInfo.Height > bestHeight {
                                bestHeight = peerInfo.Height
                        }
+
+                       m.savePeerInfo(peerInfo)
                }
                log.Info("bestHeight", bestHeight)