Skip to content

Commit

Permalink
feat: enable NoDial should still dial static nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Jan 10, 2024
1 parent 5853329 commit edc6c9d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ type Config struct {
// is used to dial outbound peer connections.
Dialer NodeDialer `toml:"-"`

// If NoDial is true, the server will not dial any peers.
// If NoDial is true, the server will not dial any peers, except for pre-configured static nodes.
NoDial bool `toml:",omitempty"`

// If EnableMsgEvents is set then the server will emit PeerEvents
Expand Down Expand Up @@ -676,7 +676,10 @@ func (srv *Server) SetFilter(f forkid.Filter) {
}

func (srv *Server) maxDialedConns() (limit int) {
if srv.NoDial || srv.MaxPeers == 0 {
if srv.NoDial {
return len(srv.StaticNodes)
}
if srv.MaxPeers == 0 {
return 0
}
if srv.DialRatio == 0 {
Expand Down

0 comments on commit edc6c9d

Please sign in to comment.