OSDN Git Service

fix https://github.com/Bytom/vapor/pull/181#discussion_r294070868
authorHAOYUatHZ <haoyu@protonmail.com>
Sun, 16 Jun 2019 08:50:05 +0000 (16:50 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Sun, 16 Jun 2019 08:50:05 +0000 (16:50 +0800)
docs/federation/README-en.md
federation/config/config.go
federation/warder.go

index 2a06a50..c6e05b9 100644 (file)
@@ -25,7 +25,6 @@ A `fed_cfg.json` would look like this:
         },
         "log_mode" : true
     },
-    "collect_pending_tx_minutes" : 5,
     "warders" : [
         {
             "position" : 1,
index 177d175..d09a394 100644 (file)
@@ -33,12 +33,11 @@ func NewConfigWithPath(path string) *Config {
 }
 
 type Config struct {
-       GinGonic       GinGonic    `json:"gin-gonic"`
-       MySQLConfig    MySQLConfig `json:"mysql"`
-       CollectMinutes uint64      `json:"collect_pending_tx_minutes"`
-       Warders        []Warder    `json:"warders"`
-       Mainchain      Chain       `json:"mainchain"`
-       Sidechain      Chain       `json:"sidechain"`
+       GinGonic    GinGonic    `json:"gin-gonic"`
+       MySQLConfig MySQLConfig `json:"mysql"`
+       Warders     []Warder    `json:"warders"`
+       Mainchain   Chain       `json:"mainchain"`
+       Sidechain   Chain       `json:"sidechain"`
 }
 
 type GinGonic struct {
index c5f0856..960df34 100644 (file)
@@ -17,6 +17,8 @@ import (
        vaporTypes "github.com/vapor/protocol/bc/types"
 )
 
+var collectInterval = 5 * time.Second
+
 type warder struct {
        position       uint8
        xpub           chainkd.XPub
@@ -31,14 +33,13 @@ type warder struct {
 func NewWarder(cfg *config.Config, db *gorm.DB) *warder {
        local, remotes := parseWarders(cfg)
        return &warder{
-               position:       local.Position,
-               xpub:           local.XPub,
-               colletInterval: time.Duration(cfg.CollectMinutes) * time.Minute,
-               db:             db,
-               txCh:           make(chan *orm.CrossTransaction),
-               mainchainNode:  service.NewNode(cfg.Mainchain.Upstream),
-               sidechainNode:  service.NewNode(cfg.Sidechain.Upstream),
-               remotes:        remotes,
+               position:      local.Position,
+               xpub:          local.XPub,
+               db:            db,
+               txCh:          make(chan *orm.CrossTransaction),
+               mainchainNode: service.NewNode(cfg.Mainchain.Upstream),
+               sidechainNode: service.NewNode(cfg.Sidechain.Upstream),
+               remotes:       remotes,
        }
 }
 
@@ -67,7 +68,7 @@ func (w *warder) Run() {
 }
 
 func (w *warder) collectPendingTx() {
-       ticker := time.NewTicker(w.colletInterval)
+       ticker := time.NewTicker(collectInterval)
        for ; true; <-ticker.C {
                txs := []*orm.CrossTransaction{}
                if err := w.db.Preload("Chain").Preload("Reqs").