go m.discovery()
go m.collectDiscv()
-
- m.cfg.CheckFreqSeconds = 60
- ticker := time.NewTicker(time.Duration(m.cfg.CheckFreqSeconds) * time.Second)
- for ; true; <-ticker.C {
- // TODO: lock?
- m.monitorRountine()
- }
+ go m.dialRoutine()
}
// create or update: https://github.com/jinzhu/gorm/issues/1307
}
}
-func (m *monitor) monitorRountine() error {
+func (m *monitor) dialRoutine() {
+ // TODO: rm hardcode
+ m.cfg.CheckFreqSeconds = 60
+ ticker := time.NewTicker(time.Duration(m.cfg.CheckFreqSeconds) * time.Second)
+ for ; true; <-ticker.C {
+ m.dialNodes()
+ }
+}
+
+func (m *monitor) dialNodes() {
var nodes []*orm.Node
if err := m.db.Model(&orm.Node{}).Find(&nodes).Error; err != nil {
- return err
+ log.Error(err)
+ return
}
addresses := make([]*p2p.NetAddress, 0)
}
m.sw.DialPeers(addresses)
-
- // TODO: dail nodes, get lantency & best_height
- // TODO: decide check_height("best best_height" - "confirmations")
- // TODO: get blockhash by check_height, get latency
- // TODO: update lantency, active_time and status
- return nil
}
// TODO:
// p2p/switch_test.go
// syncManager
// notificationMgr
+// TODO: dail nodes, get lantency & best_height
+// TODO: decide check_height("best best_height" - "confirmations")
+// TODO: get blockhash by check_height, get latency
+// TODO: update lantency, active_time and status