Move initial DNS seeding to own func.
This commit is contained in:
parent
4b728df738
commit
c03f2b757b
1 changed files with 43 additions and 35 deletions
50
server.go
50
server.go
|
@ -211,29 +211,13 @@ func (s *server) listenHandler(listener net.Listener) {
|
|||
log.Tracef("[SRVR] Listener handler done for %s", listener.Addr())
|
||||
}
|
||||
|
||||
// peerHandler is used to handle peer operations such as adding and removing
|
||||
// peers to and from the server, banning peers, and broadcasting messages to
|
||||
// peers. It must be run a a goroutine.
|
||||
func (s *server) peerHandler() {
|
||||
// Start the address manager and block manager, both of which are needed
|
||||
// by peers. This is done here since their lifecycle is closely tied
|
||||
// to this handler and rather than adding more channels to sychronize
|
||||
// things, it's easier and slightly faster to simply start and stop them
|
||||
// in this handler.
|
||||
s.addrManager.Start()
|
||||
s.blockManager.Start()
|
||||
|
||||
log.Tracef("[SRVR] Starting peer handler")
|
||||
peers := list.New()
|
||||
bannedPeers := make(map[string]time.Time)
|
||||
outboundPeers := 0
|
||||
maxOutbound := defaultMaxOutbound
|
||||
if cfg.MaxPeers < maxOutbound {
|
||||
maxOutbound = cfg.MaxPeers
|
||||
// seedFromDNS uses DNS seeding to populate the address manager with peers.
|
||||
func (s *server) seedFromDNS() {
|
||||
// Nothing to do if DNS seeding is disabled.
|
||||
if cfg.DisableDNSSeed {
|
||||
return
|
||||
}
|
||||
|
||||
// Do initial DNS seeding to populate address manager.
|
||||
if !cfg.DisableDNSSeed {
|
||||
proxy := ""
|
||||
if cfg.Proxy != "" && cfg.UseTor {
|
||||
proxy = cfg.Proxy
|
||||
|
@ -266,8 +250,32 @@ func (s *server) peerHandler() {
|
|||
}
|
||||
// XXX if this is empty do we want to use hardcoded
|
||||
// XXX peers like bitcoind does?
|
||||
}
|
||||
|
||||
// peerHandler is used to handle peer operations such as adding and removing
|
||||
// peers to and from the server, banning peers, and broadcasting messages to
|
||||
// peers. It must be run a a goroutine.
|
||||
func (s *server) peerHandler() {
|
||||
// Start the address manager and block manager, both of which are needed
|
||||
// by peers. This is done here since their lifecycle is closely tied
|
||||
// to this handler and rather than adding more channels to sychronize
|
||||
// things, it's easier and slightly faster to simply start and stop them
|
||||
// in this handler.
|
||||
s.addrManager.Start()
|
||||
s.blockManager.Start()
|
||||
|
||||
log.Tracef("[SRVR] Starting peer handler")
|
||||
peers := list.New()
|
||||
bannedPeers := make(map[string]time.Time)
|
||||
outboundPeers := 0
|
||||
maxOutbound := defaultMaxOutbound
|
||||
if cfg.MaxPeers < maxOutbound {
|
||||
maxOutbound = cfg.MaxPeers
|
||||
}
|
||||
|
||||
// Add peers discovered through DNS to the address manager.
|
||||
s.seedFromDNS()
|
||||
|
||||
// Start up persistent peers.
|
||||
permanentPeers := cfg.ConnectPeers
|
||||
if len(permanentPeers) == 0 {
|
||||
|
|
Loading…
Reference in a new issue