Use for to iterate over channel

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-09-08 12:11:30 +02:00
parent 74e577610a
commit ba9678bd61
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -42,12 +42,9 @@ func newPeerTracker(lc fx.Lifecycle, h host.Host, pmgr *peermgr.PeerMgr) *bsPeer
if err != nil { if err != nil {
panic(err) panic(err)
} }
go func() { go func() {
var newPeer interface{} for newPeer := range sub.Out() {
ok := true
for ok {
newPeer, ok = <-sub.Out()
log.Warnf("new peer from hello in tracker: %s", newPeer.(peermgr.NewFilPeer).Id)
bsPt.addPeer(newPeer.(peermgr.NewFilPeer).Id) bsPt.addPeer(newPeer.(peermgr.NewFilPeer).Id)
} }
}() }()