mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
NoDial option now effective within AddPeer -> returns error
This commit is contained in:
parent
caa651aaec
commit
13ca81544b
1 changed files with 5 additions and 9 deletions
|
|
@ -60,6 +60,8 @@ type Server struct {
|
|||
Dialer *net.Dialer
|
||||
|
||||
// If NoDial is true, the server will not dial any peers.
|
||||
// this maybe used in test environments where we want to prevent a node from
|
||||
// connecting (and synchronising) with other nodes
|
||||
NoDial bool
|
||||
|
||||
// peer selector
|
||||
|
|
@ -144,9 +146,10 @@ func (srv *Server) SuggestPeer(addr string, pubkey []byte) error {
|
|||
// If not found among connected peers turns to the peerSelector
|
||||
// to decide if it is a worthwhile connection
|
||||
func (srv *Server) AddPeer(addr *peerAddr) (err error) {
|
||||
if srv.NoDial {
|
||||
return fmt.Errorln("no dial out")
|
||||
}
|
||||
// need to look up nodeID first
|
||||
srvlog.Infof("checking peer %v", addr)
|
||||
|
||||
peer := &Peer{
|
||||
dialAddr: addr,
|
||||
lastActiveC: make(chan time.Time),
|
||||
|
|
@ -256,13 +259,6 @@ func (srv *Server) Start() (err error) {
|
|||
return err
|
||||
}
|
||||
}
|
||||
// if !srv.NoDial {
|
||||
// srv.wg.Add(1)
|
||||
// go srv.dialLoop()
|
||||
// }
|
||||
if srv.NoDial && srv.ListenAddr == "" {
|
||||
srvlog.Warnln("I will be kind-of useless, neither dialing nor listening.")
|
||||
}
|
||||
|
||||
if srv.PeerSelector == nil {
|
||||
srv.PeerSelector = &BaseSelector{}
|
||||
|
|
|
|||
Loading…
Reference in a new issue