Commit 1b402341 authored by Janos Guljas's avatar Janos Guljas

remove libp2p connection manager as we are going to track peers

parent 4b643f4b
......@@ -27,21 +27,18 @@ import (
func (c *command) initStartCmd() (err error) {
const (
optionNameDataDir = "data-dir"
optionNamePassword = "password"
optionNamePasswordFile = "password-file"
optionNameAPIAddr = "api-addr"
optionNameP2PAddr = "p2p-addr"
optionNameP2PDisableWS = "p2p-disable-ws"
optionNameP2PDisableQUIC = "p2p-disable-quic"
optionNameEnableDebugAPI = "enable-debug-api"
optionNameDebugAPIAddr = "debug-api-addr"
optionNameBootnodes = "bootnode"
optionNameNetworkID = "network-id"
optionNameConnectionsLow = "connections-low"
optionNameConnectionsHigh = "connections-high"
optionNameConnectionsGrace = "connections-grace"
optionNameVerbosity = "verbosity"
optionNameDataDir = "data-dir"
optionNamePassword = "password"
optionNamePasswordFile = "password-file"
optionNameAPIAddr = "api-addr"
optionNameP2PAddr = "p2p-addr"
optionNameP2PDisableWS = "p2p-disable-ws"
optionNameP2PDisableQUIC = "p2p-disable-quic"
optionNameEnableDebugAPI = "enable-debug-api"
optionNameDebugAPIAddr = "debug-api-addr"
optionNameBootnodes = "bootnode"
optionNameNetworkID = "network-id"
optionNameVerbosity = "verbosity"
)
cmd := &cobra.Command{
......@@ -98,15 +95,12 @@ func (c *command) initStartCmd() (err error) {
APIAddr: c.config.GetString(optionNameAPIAddr),
DebugAPIAddr: debugAPIAddr,
LibP2POptions: libp2p.Options{
Addr: c.config.GetString(optionNameP2PAddr),
DisableWS: c.config.GetBool(optionNameP2PDisableWS),
DisableQUIC: c.config.GetBool(optionNameP2PDisableQUIC),
Bootnodes: c.config.GetStringSlice(optionNameBootnodes),
NetworkID: c.config.GetInt32(optionNameNetworkID),
ConnectionsLow: c.config.GetInt(optionNameConnectionsLow),
ConnectionsHigh: c.config.GetInt(optionNameConnectionsHigh),
ConnectionsGrace: c.config.GetDuration(optionNameConnectionsGrace),
Logger: logger,
Addr: c.config.GetString(optionNameP2PAddr),
DisableWS: c.config.GetBool(optionNameP2PDisableWS),
DisableQUIC: c.config.GetBool(optionNameP2PDisableQUIC),
Bootnodes: c.config.GetStringSlice(optionNameBootnodes),
NetworkID: c.config.GetInt32(optionNameNetworkID),
Logger: logger,
},
Logger: logger,
})
......@@ -164,9 +158,6 @@ func (c *command) initStartCmd() (err error) {
cmd.Flags().Bool(optionNameEnableDebugAPI, false, "enable debug HTTP API")
cmd.Flags().String(optionNameDebugAPIAddr, ":6060", "debug HTTP API listen address")
cmd.Flags().Int32(optionNameNetworkID, 1, "ID of the Swarm network")
cmd.Flags().Int(optionNameConnectionsLow, 200, "low watermark governing the number of connections that'll be maintained")
cmd.Flags().Int(optionNameConnectionsHigh, 400, "high watermark governing the number of connections that'll be maintained")
cmd.Flags().Duration(optionNameConnectionsGrace, time.Minute, "the amount of time a newly opened connection is given before it becomes subject to pruning")
cmd.Flags().String(optionNameVerbosity, "info", "log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace")
c.root.AddCommand(cmd)
......
......@@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"net"
"time"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
......@@ -18,7 +17,6 @@ import (
"github.com/ethersphere/bee/pkg/swarm"
"github.com/libp2p/go-libp2p"
autonat "github.com/libp2p/go-libp2p-autonat-svc"
connmgr "github.com/libp2p/go-libp2p-connmgr"
crypto "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
......@@ -44,17 +42,14 @@ type Service struct {
}
type Options struct {
PrivateKey *ecdsa.PrivateKey
Overlay swarm.Address
Addr string
DisableWS bool
DisableQUIC bool
Bootnodes []string
NetworkID int32
ConnectionsLow int
ConnectionsHigh int
ConnectionsGrace time.Duration
Logger logging.Logger
PrivateKey *ecdsa.PrivateKey
Overlay swarm.Address
Addr string
DisableWS bool
DisableQUIC bool
Bootnodes []string
NetworkID int32
Logger logging.Logger
}
func New(ctx context.Context, o Options) (*Service, error) {
......@@ -107,13 +102,6 @@ func New(ctx context.Context, o Options) (*Service, error) {
libp2p.Security(secio.ID, secio.New),
// support any other default transports (TCP)
libp2p.DefaultTransports,
// Let's prevent our peer from having too many
// connections by attaching a connection manager.
libp2p.ConnectionManager(connmgr.NewConnManager(
o.ConnectionsLow,
o.ConnectionsHigh,
o.ConnectionsGrace,
)),
// Attempt to open ports using uPNP for NATed hosts.
libp2p.NATPortMap(),
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment