connmgr: Remove deprecated SeedFromDNS func.
This removes the deprecated SeedFromDNS function and associated LookupFunc type since the major version has been bumped since the last release.
This commit is contained in:
parent
93060bdb8d
commit
fba0da4c1b
@ -29,54 +29,9 @@ const (
|
||||
// seeding is successful.
|
||||
type OnSeed func(addrs []*wire.NetAddress)
|
||||
|
||||
// LookupFunc is the signature of the DNS lookup function.
|
||||
type LookupFunc func(string) ([]net.IP, error)
|
||||
|
||||
// DialFunc is the signature of the Dialer function.
|
||||
type DialFunc func(context.Context, string, string) (net.Conn, error)
|
||||
|
||||
// SeedFromDNS uses DNS seeding to populate the address manager with peers.
|
||||
//
|
||||
// Deprecated: This will be removed in the next major version bump.
|
||||
func SeedFromDNS(dnsSeeds []string, defaultPort uint16, reqServices wire.ServiceFlag, lookupFn LookupFunc, seedFn OnSeed) {
|
||||
for _, seed := range dnsSeeds {
|
||||
host := seed
|
||||
if reqServices != wire.SFNodeNetwork {
|
||||
host = fmt.Sprintf("x%x.%s", uint64(reqServices), seed)
|
||||
}
|
||||
|
||||
go func(host string) {
|
||||
randSource := mrand.New(mrand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
seedpeers, err := lookupFn(host)
|
||||
if err != nil {
|
||||
log.Infof("DNS discovery failed on seed %s: %v", host, err)
|
||||
return
|
||||
}
|
||||
numPeers := len(seedpeers)
|
||||
|
||||
log.Infof("%d addresses found from DNS seed %s", numPeers, host)
|
||||
|
||||
if numPeers == 0 {
|
||||
return
|
||||
}
|
||||
addresses := make([]*wire.NetAddress, len(seedpeers))
|
||||
// if this errors then we have *real* problems
|
||||
for i, peer := range seedpeers {
|
||||
addresses[i] = wire.NewNetAddressTimestamp(
|
||||
// bitcoind seeds with addresses from
|
||||
// a time randomly selected between 3
|
||||
// and 7 days ago.
|
||||
time.Now().Add(-1*time.Second*time.Duration(secondsIn3Days+
|
||||
randSource.Int31n(secondsIn4Days))),
|
||||
0, peer, defaultPort)
|
||||
}
|
||||
|
||||
seedFn(addresses)
|
||||
}(host)
|
||||
}
|
||||
}
|
||||
|
||||
// node defines a single JSON object returned by the https seeders.
|
||||
type node struct {
|
||||
Host string `json:"host"`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user