[DEV-363] Refactoring DNS seeder (#192)

* [DEV-363] Refactoring DNS seeder

* [DEV-363] Fixed comment
This commit is contained in:
Evgeny Khirin 2019-03-06 13:24:25 +02:00 committed by Svarog
parent 5e15b8208e
commit 00692a4236

View File

@ -22,6 +22,12 @@ const (
// seen time.
secondsIn3Days int32 = 24 * 60 * 60 * 3
secondsIn4Days int32 = 24 * 60 * 60 * 4
// SubnetworkIDPrefixChar is the prefix of subnetworkID, when building a DNS seed request
SubnetworkIDPrefixChar byte = 'n'
// ServiceFlagPrefixChar is the prefix of service flag, when building a DNS seed request
ServiceFlagPrefixChar byte = 'x'
)
// OnSeed is the signature of the callback function which is invoked when DNS
@ -40,11 +46,11 @@ func SeedFromDNS(dagParams *dagconfig.Params, reqServices wire.ServiceFlag, subn
if !dnsseed.HasFiltering || reqServices == wire.SFNodeNetwork {
host = dnsseed.Host
} else {
host = fmt.Sprintf("x%x.%s", uint64(reqServices), dnsseed.Host)
host = fmt.Sprintf("%c%x.%s", ServiceFlagPrefixChar, uint64(reqServices), dnsseed.Host)
}
if !subnetworkID.IsEqual(&wire.SubnetworkIDSupportsAll) {
host = fmt.Sprintf("n%s.%s", subnetworkID, host)
host = fmt.Sprintf("%c%s.%s", SubnetworkIDPrefixChar, subnetworkID, host)
}
go func(host string) {