OSDN Git Service

add
authorHAOYUatHZ <haoyu@protonmail.com>
Fri, 2 Aug 2019 02:37:10 +0000 (10:37 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Fri, 2 Aug 2019 02:37:10 +0000 (10:37 +0800)
cmd/precog/main.go
toolbar/precog/config/config.go

index da29a2c..9a13e16 100644 (file)
@@ -1,4 +1,21 @@
 package main
 
+import (
+       "sync"
+
+       "github.com/vapor/toolbar/common"
+       "github.com/vapor/toolbar/precog/config"
+)
+
 func main() {
+       cfg := config.NewConfig()
+       db, err := common.NewMySQLDB(cfg.MySQLConfig)
+       if err != nil {
+               log.WithField("err", err).Panic("initialize mysql db error")
+       }
+
+       // keep the main func running in case of terminating goroutines
+       var wg sync.WaitGroup
+       wg.Add(1)
+       wg.Wait()
 }
index 2defec0..ee67f7b 100644 (file)
@@ -5,8 +5,8 @@ import (
        "os"
 
        log "github.com/sirupsen/logrus"
+       "github.com/vapor/crypto/ed25519/chainkd"
 
-       vaporJson "github.com/vapor/encoding/json"
        "github.com/vapor/toolbar/common"
 )
 
@@ -32,3 +32,19 @@ func NewConfigWithPath(path string) *Config {
 
        return cfg
 }
+
+type Config struct {
+       Policy      Policy             `json:"policy"`
+       MySQLConfig common.MySQLConfig `json:"mysql"`
+       Nodes       []Node             `json:"nodes"`
+}
+
+type Policy struct {
+       LantencyMS uint64 `json:"lantency_ms"`
+}
+
+type Node struct {
+       Alias    string       `json:"alias"`
+       HostPort string       `json:"host_port"`
+       PubKey   chainkd.XPub `json:"pubkey"`
+}