From 7f6c78b763f00bd5069c751f5384c79c2e1f86cc Mon Sep 17 00:00:00 2001 From: rkonfj Date: Sat, 20 Jul 2024 09:03:40 +0800 Subject: [PATCH] disco: remove unused code --- disco/udp.go | 4 ---- p2p/conn.go | 6 ++---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/disco/udp.go b/disco/udp.go index 0776ba7..0145e05 100644 --- a/disco/udp.go +++ b/disco/udp.go @@ -31,7 +31,6 @@ type UDPConfig struct { DisableIPv4 bool DisableIPv6 bool ID peer.ID - NetworkDetectInterval time.Duration PeerKeepaliveInterval time.Duration DiscoMagic func() []byte } @@ -503,9 +502,6 @@ func ListenUDP(cfg UDPConfig) (*UDPConn, error) { if cfg.ID.Len() == 0 { return nil, errors.New("peer id is required") } - if cfg.NetworkDetectInterval < time.Second { - cfg.NetworkDetectInterval = 5 * time.Second - } if cfg.PeerKeepaliveInterval < time.Second { cfg.PeerKeepaliveInterval = 10 * time.Second } diff --git a/p2p/conn.go b/p2p/conn.go index 7d35ba6..49d5866 100644 --- a/p2p/conn.go +++ b/p2p/conn.go @@ -99,10 +99,7 @@ func (c *PeerPacketConn) Close() error { if err := c.udpConn.Close(); err != nil { errs = append(errs, err) } - if len(errs) > 0 { - return errors.Join(errs...) - } - return nil + return errors.Join(errs...) } // LocalAddr returns the local network address, if known. @@ -214,6 +211,7 @@ func (c *PeerPacketConn) SharedKey(peerID peer.ID) ([]byte, error) { return c.cfg.SymmAlgo.SecretKey()(peerID.String()) } +// runAddrUpdateEventLoop listen network change and restart udp and websocket listener func (c *PeerPacketConn) runAddrUpdateEventLoop() { ctx, cancel := context.WithCancel(context.Background()) defer cancel()