chaincfg: Move DNS Seeds to chaincfg.

This allows API users access to the DNS Seeds for use with SPV
clients, seeders, etc.
This commit is contained in:
David Hill 2015-11-09 17:21:16 -05:00
parent aa0efa1f3e
commit cb71f278ec
3 changed files with 24 additions and 24 deletions

View file

@ -55,6 +55,7 @@ type Params struct {
Name string Name string
Net wire.BitcoinNet Net wire.BitcoinNet
DefaultPort string DefaultPort string
DNSSeeds []string
// Chain parameters // Chain parameters
GenesisBlock *wire.MsgBlock GenesisBlock *wire.MsgBlock
@ -101,6 +102,15 @@ var MainNetParams = Params{
Name: "mainnet", Name: "mainnet",
Net: wire.MainNet, Net: wire.MainNet,
DefaultPort: "8333", DefaultPort: "8333",
DNSSeeds: []string{
"seed.bitcoin.sipa.be",
"dnsseed.bluematt.me",
"dnsseed.bitcoin.dashjr.org",
"seed.bitcoinstats.com",
"seed.bitnodes.io",
"bitseed.xf2.org",
"seed.bitcoin.jonasschnelli.ch",
},
// Chain parameters // Chain parameters
GenesisBlock: &genesisBlock, GenesisBlock: &genesisBlock,
@ -166,6 +176,7 @@ var RegressionNetParams = Params{
Name: "regtest", Name: "regtest",
Net: wire.TestNet, Net: wire.TestNet,
DefaultPort: "18444", DefaultPort: "18444",
DNSSeeds: []string{},
// Chain parameters // Chain parameters
GenesisBlock: &regTestGenesisBlock, GenesisBlock: &regTestGenesisBlock,
@ -213,6 +224,12 @@ var TestNet3Params = Params{
Name: "testnet3", Name: "testnet3",
Net: wire.TestNet3, Net: wire.TestNet3,
DefaultPort: "18333", DefaultPort: "18333",
DNSSeeds: []string{
"testnet-seed.alexykot.me",
"testnet-seed.bitcoin.schildbach.de",
"testnet-seed.bitcoin.petertodd.org",
"testnet-seed.bluematt.me",
},
// Chain parameters // Chain parameters
GenesisBlock: &testNet3GenesisBlock, GenesisBlock: &testNet3GenesisBlock,
@ -266,6 +283,7 @@ var SimNetParams = Params{
Name: "simnet", Name: "simnet",
Net: wire.SimNet, Net: wire.SimNet,
DefaultPort: "18555", DefaultPort: "18555",
DNSSeeds: []string{}, // NOTE: There must NOT be any seeds.
// Chain parameters // Chain parameters
GenesisBlock: &simNetGenesisBlock, GenesisBlock: &simNetGenesisBlock,

View file

@ -18,7 +18,6 @@ var activeNetParams = &mainNetParams
type params struct { type params struct {
*chaincfg.Params *chaincfg.Params
rpcPort string rpcPort string
dnsSeeds []string
} }
// mainNetParams contains parameters specific to the main network // mainNetParams contains parameters specific to the main network
@ -30,15 +29,6 @@ type params struct {
var mainNetParams = params{ var mainNetParams = params{
Params: &chaincfg.MainNetParams, Params: &chaincfg.MainNetParams,
rpcPort: "8334", rpcPort: "8334",
dnsSeeds: []string{
"seed.bitcoin.sipa.be",
"dnsseed.bluematt.me",
"dnsseed.bitcoin.dashjr.org",
"seed.bitcoinstats.com",
"seed.bitnodes.io",
"bitseed.xf2.org",
"seed.bitcoin.jonasschnelli.ch",
},
} }
// regressionNetParams contains parameters specific to the regression test // regressionNetParams contains parameters specific to the regression test
@ -48,7 +38,6 @@ var mainNetParams = params{
var regressionNetParams = params{ var regressionNetParams = params{
Params: &chaincfg.RegressionNetParams, Params: &chaincfg.RegressionNetParams,
rpcPort: "18334", rpcPort: "18334",
dnsSeeds: []string{},
} }
// testNet3Params contains parameters specific to the test network (version 3) // testNet3Params contains parameters specific to the test network (version 3)
@ -57,12 +46,6 @@ var regressionNetParams = params{
var testNet3Params = params{ var testNet3Params = params{
Params: &chaincfg.TestNet3Params, Params: &chaincfg.TestNet3Params,
rpcPort: "18334", rpcPort: "18334",
dnsSeeds: []string{
"testnet-seed.alexykot.me",
"testnet-seed.bitcoin.schildbach.de",
"testnet-seed.bitcoin.petertodd.org",
"testnet-seed.bluematt.me",
},
} }
// simNetParams contains parameters specific to the simulation test network // simNetParams contains parameters specific to the simulation test network
@ -70,7 +53,6 @@ var testNet3Params = params{
var simNetParams = params{ var simNetParams = params{
Params: &chaincfg.SimNetParams, Params: &chaincfg.SimNetParams,
rpcPort: "18556", rpcPort: "18556",
dnsSeeds: []string{}, // NOTE: There must NOT be any seeds.
} }
// netName returns the name used when referring to a bitcoin network. At the // netName returns the name used when referring to a bitcoin network. At the

View file

@ -1429,7 +1429,7 @@ func (s *server) seedFromDNS() {
return return
} }
for _, seeder := range activeNetParams.dnsSeeds { for _, seeder := range activeNetParams.DNSSeeds {
go func(seeder string) { go func(seeder string) {
randSource := mrand.New(mrand.NewSource(time.Now().UnixNano())) randSource := mrand.New(mrand.NewSource(time.Now().UnixNano()))