mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
p2p/server: expose MaxInboundConns and MaxDialedConns
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
23cda63d5a
commit
ea8d05a1c9
1 changed files with 5 additions and 5 deletions
|
|
@ -511,7 +511,7 @@ func (srv *Server) setupDiscovery() error {
|
|||
func (srv *Server) setupDialScheduler() {
|
||||
config := dialConfig{
|
||||
self: srv.localnode.ID(),
|
||||
maxDialPeers: srv.maxDialedConns(),
|
||||
maxDialPeers: srv.MaxDialedConns(),
|
||||
maxActiveDials: srv.MaxPendingPeers,
|
||||
log: srv.Logger,
|
||||
netRestrict: srv.NetRestrict,
|
||||
|
|
@ -535,11 +535,11 @@ func (srv *Server) setupConnManager() {
|
|||
srv.connman = newConnManager(config, srv.Peers)
|
||||
}
|
||||
|
||||
func (srv *Server) maxInboundConns() int {
|
||||
return srv.MaxPeers - srv.maxDialedConns()
|
||||
func (srv *Server) MaxInboundConns() int {
|
||||
return srv.MaxPeers - srv.MaxDialedConns()
|
||||
}
|
||||
|
||||
func (srv *Server) maxDialedConns() (limit int) {
|
||||
func (srv *Server) MaxDialedConns() (limit int) {
|
||||
if srv.NoDial || srv.MaxPeers == 0 {
|
||||
return 0
|
||||
}
|
||||
|
|
@ -746,7 +746,7 @@ func (srv *Server) postHandshakeChecks(peers map[enode.ID]*Peer, inboundCount in
|
|||
switch {
|
||||
case !c.is(trustedConn) && len(peers) >= srv.MaxPeers:
|
||||
return DiscTooManyPeers
|
||||
case !c.is(trustedConn) && c.is(inboundConn) && inboundCount >= srv.maxInboundConns():
|
||||
case !c.is(trustedConn) && c.is(inboundConn) && inboundCount >= srv.MaxInboundConns():
|
||||
return DiscTooManyPeers
|
||||
case peers[c.node.ID()] != nil:
|
||||
return DiscAlreadyConnected
|
||||
|
|
|
|||
Loading…
Reference in a new issue