• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision0cd03c0fb32a2e99cad0b69caef1ef583fd44e39 (tree)
Time2019-08-14 10:12:37
AuthorHAOYUatHZ <haoyu@prot...>
CommiterHAOYUatHZ

Log Message

clean

Change Summary

Incremental Difference

--- a/toolbar/precog/monitor/monitor.go
+++ b/toolbar/precog/monitor/monitor.go
@@ -42,7 +42,7 @@ type monitor struct {
4242 }
4343
4444 func NewMonitor(cfg *config.Config, db *gorm.DB) *monitor {
45- // for test
45+ //TODO: for test
4646 cfg.CheckFreqSeconds = 1
4747
4848 nodeCfg := &vaporCfg.Config{
@@ -76,13 +76,7 @@ func (m *monitor) Run() {
7676 m.upSertNode(&node)
7777 }
7878 m.nodeCfg.P2P.Seeds = strings.Join(seeds, ",")
79-
80- sw, err := m.makeSwitch()
81- if err != nil {
82- log.Fatal(err)
83- }
84-
85- m.sw = sw
79+ m.makeSwitch()
8680
8781 go m.discovery()
8882 go m.collectDiscv()
@@ -122,16 +116,21 @@ func (m *monitor) upSertNode(node *config.Node) error {
122116 }).FirstOrCreate(ormNode).Error
123117 }
124118
125-func (m *monitor) makeSwitch() (*p2p.Switch, error) {
119+func (m *monitor) makeSwitch() {
126120 l, listenAddr := p2p.GetListener(m.nodeCfg.P2P)
127121 discv, err := dht.NewDiscover(m.nodeCfg, m.privKey, l.ExternalAddress().Port, m.cfg.NetworkID)
128122 if err != nil {
129- return nil, err
123+ log.Fatal(err)
130124 }
131125
132126 // no need for lanDiscv, but passing &mdns.LANDiscover{} will cause NilPointer
133127 lanDiscv := mdns.NewLANDiscover(mdns.NewProtocol(), int(l.ExternalAddress().Port))
134- return p2p.NewSwitch(m.nodeCfg, discv, lanDiscv, l, m.privKey, listenAddr, m.cfg.NetworkID)
128+ sw, err := p2p.NewSwitch(m.nodeCfg, discv, lanDiscv, l, m.privKey, listenAddr, m.cfg.NetworkID)
129+ if err != nil {
130+ log.Fatal(err)
131+ }
132+
133+ m.sw = sw
135134 }
136135
137136 func (m *monitor) discovery() {
Show on old repository browser