diff --git a/crawler/crawler.go b/crawler/crawler.go index 4c243e81..922568c0 100644 --- a/crawler/crawler.go +++ b/crawler/crawler.go @@ -32,12 +32,11 @@ type ( } // DefaultCrawler provides a default implementation of Crawler. DefaultCrawler struct { - parallelism int - connectTimeout time.Duration - queryTimeout time.Duration - host host.Host - dhtRPC *pb.ProtocolMessenger - dialAddressExtendDur time.Duration + parallelism int + connectTimeout time.Duration + queryTimeout time.Duration + host host.Host + dhtRPC *pb.ProtocolMessenger } ) @@ -59,12 +58,11 @@ func NewDefaultCrawler(host host.Host, opts ...Option) (*DefaultCrawler, error) } return &DefaultCrawler{ - parallelism: o.parallelism, - connectTimeout: o.connectTimeout, - queryTimeout: 3 * o.connectTimeout, - host: host, - dhtRPC: pm, - dialAddressExtendDur: o.dialAddressExtendDur, + parallelism: o.parallelism, + connectTimeout: o.connectTimeout, + queryTimeout: 3 * o.connectTimeout, + host: host, + dhtRPC: pm, }, nil } @@ -300,11 +298,6 @@ func (c *DefaultCrawler) queryPeer(ctx context.Context, nextPeer peer.AddrInfo) logger.Debugf("could not connect to peer %v: %v", nextPeer.ID, err) return &queryResult{nextPeer.ID, nil, err} } - // Extend peerstore address ttl for addresses whose ttl is below - // c.dialAddressExtendDur. By now identify has already cleaned up addresses - // provided to Connect above and only kept the listen addresses advertised by - // the remote peer - c.host.Peerstore().AddAddrs(nextPeer.ID, c.host.Peerstore().Addrs(nextPeer.ID), c.dialAddressExtendDur) localPeers := make(map[peer.ID]*peer.AddrInfo) var retErr error diff --git a/crawler/options.go b/crawler/options.go index 649b4d6f..4a241eaa 100644 --- a/crawler/options.go +++ b/crawler/options.go @@ -11,11 +11,10 @@ import ( type Option func(*options) error type options struct { - protocols []protocol.ID - parallelism int - connectTimeout time.Duration - perMsgTimeout time.Duration - dialAddressExtendDur time.Duration + protocols []protocol.ID + parallelism int + connectTimeout time.Duration + perMsgTimeout time.Duration } // defaults are the default crawler options. This option will be automatically @@ -25,7 +24,6 @@ var defaults = func(o *options) error { o.parallelism = 1000 o.connectTimeout = time.Second * 5 o.perMsgTimeout = time.Second * 5 - o.dialAddressExtendDur = time.Minute * 30 return nil } @@ -61,13 +59,3 @@ func WithConnectTimeout(timeout time.Duration) Option { return nil } } - -// WithDialAddrExtendDuration sets the duration by which the TTL of dialed address in peer store are -// extended. -// Defaults to 30 minutes if unset. -func WithDialAddrExtendDuration(ext time.Duration) Option { - return func(o *options) error { - o.dialAddressExtendDur = ext - return nil - } -} diff --git a/fullrt/dht.go b/fullrt/dht.go index 2d15fd1f..6d6c36bf 100644 --- a/fullrt/dht.go +++ b/fullrt/dht.go @@ -163,7 +163,7 @@ func NewFullRT(h host.Host, protocolPrefix protocol.ID, options ...Option) (*Ful } if fullrtcfg.crawler == nil { - fullrtcfg.crawler, err = crawler.NewDefaultCrawler(h, crawler.WithParallelism(200), crawler.WithDialAddrExtendDuration(fullrtcfg.crawlInterval)) + fullrtcfg.crawler, err = crawler.NewDefaultCrawler(h, crawler.WithParallelism(200)) if err != nil { return nil, err }