}
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 {
vaporTypes "github.com/vapor/protocol/bc/types"
)
+var collectInterval = 5 * time.Second
+
type warder struct {
position uint8
xpub chainkd.XPub
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,
}
}
}
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").