@@ -31,7 +31,6 @@ import (
3131 libp2ppeer "github.com/libp2p/go-libp2p/core/peer"
3232 "github.com/libp2p/go-libp2p/core/peerstore"
3333 "github.com/libp2p/go-libp2p/core/protocol"
34- "github.com/libp2p/go-libp2p/p2p/host/autonat"
3534 basichost "github.com/libp2p/go-libp2p/p2p/host/basic"
3635 "github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
3736 rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
@@ -49,7 +48,6 @@ type Service struct {
4948 host host.Host
5049 natManager basichost.NATManager
5150 natAddrResolver * staticAddressResolver
52- autonatDialer host.Host
5351 pingDialer host.Host
5452 libp2pPeerstore peerstore.Peerstore
5553 networkID uint64
@@ -70,7 +68,6 @@ type Service struct {
7068 reacher p2p.Reacher
7169 networkStatus atomic.Int32
7270 HeadersRWTimeout time.Duration
73- autoNAT autonat.AutoNAT
7471}
7572
7673type Options struct {
@@ -162,13 +159,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
162159 return nil , err
163160 }
164161
165- // Support same non default security and transport options as
166- // original host.
167- dialer , err := o .hostFactory (append (transports , security )... )
168- if err != nil {
169- return nil , err
170- }
171-
172162 if o .HeadersRWTimeout == 0 {
173163 o .HeadersRWTimeout = defaultHeadersRWTimeout
174164 }
@@ -208,7 +198,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
208198 host : h ,
209199 natManager : nil ,
210200 natAddrResolver : natAddrResolver ,
211- autonatDialer : dialer ,
212201 pingDialer : pingDialer ,
213202 handshakeService : handshakeService ,
214203 libp2pPeerstore : libp2pPeerstore ,
@@ -223,7 +212,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
223212 halt : make (chan struct {}),
224213 lightNodes : lightNodes ,
225214 HeadersRWTimeout : o .HeadersRWTimeout ,
226- autoNAT : nil ,
227215 }
228216
229217 peerRegistry .setDisconnecter (s )
@@ -726,3 +714,25 @@ func (s *Service) newStreamForPeerID(ctx context.Context, peerID libp2ppeer.ID,
726714 }
727715 return st , nil
728716}
717+
718+ func (s * Service ) Close () error {
719+ if err := s .libp2pPeerstore .Close (); err != nil {
720+ return err
721+ }
722+ if s .natManager != nil {
723+ if err := s .natManager .Close (); err != nil {
724+ return err
725+ }
726+ }
727+
728+ if err := s .pingDialer .Close (); err != nil {
729+ return err
730+ }
731+ if s .reacher != nil {
732+ if err := s .reacher .Close (); err != nil {
733+ return err
734+ }
735+ }
736+
737+ return s .host .Close ()
738+ }
0 commit comments