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 ( ...@@ -27,21 +27,18 @@ import (
func (c *command) initStartCmd() (err error) { func (c *command) initStartCmd() (err error) {
const ( const (
optionNameDataDir = "data-dir" optionNameDataDir = "data-dir"
optionNamePassword = "password" optionNamePassword = "password"
optionNamePasswordFile = "password-file" optionNamePasswordFile = "password-file"
optionNameAPIAddr = "api-addr" optionNameAPIAddr = "api-addr"
optionNameP2PAddr = "p2p-addr" optionNameP2PAddr = "p2p-addr"
optionNameP2PDisableWS = "p2p-disable-ws" optionNameP2PDisableWS = "p2p-disable-ws"
optionNameP2PDisableQUIC = "p2p-disable-quic" optionNameP2PDisableQUIC = "p2p-disable-quic"
optionNameEnableDebugAPI = "enable-debug-api" optionNameEnableDebugAPI = "enable-debug-api"
optionNameDebugAPIAddr = "debug-api-addr" optionNameDebugAPIAddr = "debug-api-addr"
optionNameBootnodes = "bootnode" optionNameBootnodes = "bootnode"
optionNameNetworkID = "network-id" optionNameNetworkID = "network-id"
optionNameConnectionsLow = "connections-low" optionNameVerbosity = "verbosity"
optionNameConnectionsHigh = "connections-high"
optionNameConnectionsGrace = "connections-grace"
optionNameVerbosity = "verbosity"
) )
cmd := &cobra.Command{ cmd := &cobra.Command{
...@@ -98,15 +95,12 @@ func (c *command) initStartCmd() (err error) { ...@@ -98,15 +95,12 @@ func (c *command) initStartCmd() (err error) {
APIAddr: c.config.GetString(optionNameAPIAddr), APIAddr: c.config.GetString(optionNameAPIAddr),
DebugAPIAddr: debugAPIAddr, DebugAPIAddr: debugAPIAddr,
LibP2POptions: libp2p.Options{ LibP2POptions: libp2p.Options{
Addr: c.config.GetString(optionNameP2PAddr), Addr: c.config.GetString(optionNameP2PAddr),
DisableWS: c.config.GetBool(optionNameP2PDisableWS), DisableWS: c.config.GetBool(optionNameP2PDisableWS),
DisableQUIC: c.config.GetBool(optionNameP2PDisableQUIC), DisableQUIC: c.config.GetBool(optionNameP2PDisableQUIC),
Bootnodes: c.config.GetStringSlice(optionNameBootnodes), Bootnodes: c.config.GetStringSlice(optionNameBootnodes),
NetworkID: c.config.GetInt32(optionNameNetworkID), NetworkID: c.config.GetInt32(optionNameNetworkID),
ConnectionsLow: c.config.GetInt(optionNameConnectionsLow), Logger: logger,
ConnectionsHigh: c.config.GetInt(optionNameConnectionsHigh),
ConnectionsGrace: c.config.GetDuration(optionNameConnectionsGrace),
Logger: logger,
}, },
Logger: logger, Logger: logger,
}) })
...@@ -164,9 +158,6 @@ func (c *command) initStartCmd() (err error) { ...@@ -164,9 +158,6 @@ func (c *command) initStartCmd() (err error) {
cmd.Flags().Bool(optionNameEnableDebugAPI, false, "enable debug HTTP API") cmd.Flags().Bool(optionNameEnableDebugAPI, false, "enable debug HTTP API")
cmd.Flags().String(optionNameDebugAPIAddr, ":6060", "debug HTTP API listen address") cmd.Flags().String(optionNameDebugAPIAddr, ":6060", "debug HTTP API listen address")
cmd.Flags().Int32(optionNameNetworkID, 1, "ID of the Swarm network") 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") cmd.Flags().String(optionNameVerbosity, "info", "log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace")
c.root.AddCommand(cmd) c.root.AddCommand(cmd)
......
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"time"
"github.com/ethersphere/bee/pkg/logging" "github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p" "github.com/ethersphere/bee/pkg/p2p"
...@@ -18,7 +17,6 @@ import ( ...@@ -18,7 +17,6 @@ import (
"github.com/ethersphere/bee/pkg/swarm" "github.com/ethersphere/bee/pkg/swarm"
"github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p"
autonat "github.com/libp2p/go-libp2p-autonat-svc" autonat "github.com/libp2p/go-libp2p-autonat-svc"
connmgr "github.com/libp2p/go-libp2p-connmgr"
crypto "github.com/libp2p/go-libp2p-core/crypto" crypto "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/helpers" "github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/host"
...@@ -44,17 +42,14 @@ type Service struct { ...@@ -44,17 +42,14 @@ type Service struct {
} }
type Options struct { type Options struct {
PrivateKey *ecdsa.PrivateKey PrivateKey *ecdsa.PrivateKey
Overlay swarm.Address Overlay swarm.Address
Addr string Addr string
DisableWS bool DisableWS bool
DisableQUIC bool DisableQUIC bool
Bootnodes []string Bootnodes []string
NetworkID int32 NetworkID int32
ConnectionsLow int Logger logging.Logger
ConnectionsHigh int
ConnectionsGrace time.Duration
Logger logging.Logger
} }
func New(ctx context.Context, o Options) (*Service, error) { func New(ctx context.Context, o Options) (*Service, error) {
...@@ -107,13 +102,6 @@ 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), libp2p.Security(secio.ID, secio.New),
// support any other default transports (TCP) // support any other default transports (TCP)
libp2p.DefaultTransports, 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. // Attempt to open ports using uPNP for NATed hosts.
libp2p.NATPortMap(), 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