• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision0c3637192af6458897366fcc71d4228686429eb2 (tree)
Time2019-08-14 16:40:14
AuthorHAOYUatHZ <haoyu@prot...>
CommiterHAOYUatHZ

Log Message

add peers for reactors

Change Summary

Incremental Difference

--- a/p2p/switch.go
+++ b/p2p/switch.go
@@ -138,10 +138,15 @@ func NewSwitch(config *cfg.Config, discv discv, lanDiscv lanDiscv, l Listener, p
138138 func (sw *Switch) GetDiscv() discv {
139139 return sw.discv
140140 }
141+
141142 func (sw *Switch) GetPeers() *PeerSet {
142143 return sw.peers
143144 }
144145
146+func (sw *Switch) GetReactors() map[string]Reactor {
147+ return sw.reactors
148+}
149+
145150 // OnStart implements BaseService. It starts all the reactors, peers, and listeners.
146151 func (sw *Switch) OnStart() error {
147152 for _, reactor := range sw.reactors {
--- a/toolbar/precog/monitor/monitor.go
+++ b/toolbar/precog/monitor/monitor.go
@@ -212,16 +212,22 @@ func (m *monitor) checkStatusRoutine() {
212212 // consensusMgr := consensusmgr.NewManager(sw, chain, peers, dispatcher)
213213 consensusMgr := consensusmgr.NewManager(m.sw, nil, peers, dispatcher)
214214 consensusMgr.Start()
215-
216215 // TODO: change name?
217216 ticker := time.NewTicker(time.Duration(m.cfg.CheckFreqSeconds) * time.Second)
218217 for ; true; <-ticker.C {
219- log.Debug("p2p.peer list", m.sw.GetPeers().List())
218+ for k, v := range m.sw.GetReactors() {
219+ log.Debug(k, ",", v)
220+ for _, peer := range m.sw.GetPeers().List() {
221+ log.Debug("AddPeer for", v, peer)
222+ v.AddPeer(peer)
223+ }
224+ }
225+
220226 // TODO: SFSPV?
221- // TODO: shit......
222- log.Info("peers", peers)
223227 log.Info("best", peers.BestPeer(consensus.SFFullNode))
224- log.Info("GetPeerInfos", peers.GetPeerInfos())
228+ for _, peerInfo := range peers.GetPeerInfos() {
229+ log.Info(peerInfo)
230+ }
225231 }
226232 }
227233
Show on old repository browser