From 7bf5934d8516096dfa31722ab6b5f05497059239 Mon Sep 17 00:00:00 2001 From: snyh Date: Fri, 4 Jun 2021 16:19:30 +0800 Subject: [PATCH] perf/basic_host: Don't handle address change if we hasn't anyone --- p2p/host/basic/basic_host.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index d0c23af9aa..54470a86df 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -520,8 +520,11 @@ func (h *BasicHost) background() { defer ticker.Stop() for { - h.updateLocalIpAddr() - curr := h.Addrs() + var curr []ma.Multiaddr + if len(h.network.ListenAddresses()) > 0 { + h.updateLocalIpAddr() + curr = h.Addrs() + } emitAddrChange(curr, lastAddrs) lastAddrs = curr