Skip to content

Commit

Permalink
start mdns service when new
Browse files Browse the repository at this point in the history
  • Loading branch information
bysomeone committed Sep 13, 2023
1 parent cc83394 commit fa0e210
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 5 additions & 0 deletions system/p2p/dht/extension/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func NewMDNS(ctx context.Context, peerhost host.Host, serviceTag string) (*MDNS,
notifee := &discoveryNotifee{}
notifee.PeerChan = make(chan peer.AddrInfo, 1)
ser := discovery.NewMdnsService(peerhost, serviceTag, notifee)
err := ser.Start()
if err != nil {
log.Error("NewMDNS", "start mdns service err", err)
return nil, err

Check warning on line 36 in system/p2p/dht/extension/mdns.go

View check run for this annotation

Codecov / codecov/patch

system/p2p/dht/extension/mdns.go#L35-L36

Added lines #L35 - L36 were not covered by tests
}
mnds := new(MDNS)
mnds.Service = ser
mnds.notifee = notifee
Expand Down
4 changes: 0 additions & 4 deletions system/p2p/dht/extension/mdns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ func Test_mdns(t *testing.T) {
hosts := getNetHosts(2, t)
tmdns, err := NewMDNS(ctx, hosts[0], "33test123")

Check failure on line 15 in system/p2p/dht/extension/mdns_test.go

View workflow job for this annotation

GitHub Actions / check_fmt

ineffectual assignment to tmdns (ineffassign)
require.Nil(t, err)
require.Nil(t, tmdns.Service.Start())
//_, err = NewMDNS(ctx, hosts[1], "33test123")
//require.Nil(t, err)
tmdns, err = NewMDNS(ctx, hosts[1], "33test123")
require.Nil(t, err)
require.Nil(t, tmdns.Service.Start())

select {
case peerinfo := <-tmdns.PeerChan():
Expand Down

0 comments on commit fa0e210

Please sign in to comment.