diff --git a/p2p/host.go b/p2p/host.go index 18dce6a46..4a4240c56 100644 --- a/p2p/host.go +++ b/p2p/host.go @@ -11,6 +11,13 @@ import ( "sync" "time" + "github.com/harmony-one/bls/ffi/go/bls" + nodeconfig "github.com/harmony-one/harmony/internal/configs/node" + "github.com/harmony-one/harmony/internal/utils" + "github.com/harmony-one/harmony/internal/utils/blockedpeers" + "github.com/harmony-one/harmony/p2p/discovery" + "github.com/harmony-one/harmony/p2p/security" + sttypes "github.com/harmony-one/harmony/p2p/stream/types" "github.com/libp2p/go-libp2p" dht "github.com/libp2p/go-libp2p-kad-dht" libp2p_pubsub "github.com/libp2p/go-libp2p-pubsub" @@ -247,7 +254,7 @@ func NewHost(cfg HostConfig) (Host, error) { subLogger := utils.Logger().With().Str("hostID", p2pHost.ID().Pretty()).Logger() banned := blockedpeers.NewManager(1024) - security := security.NewManager(cfg.MaxConnPerIP, int(cfg.MaxPeers, banned)) + security := security.NewManager(cfg.MaxConnPerIP, int(cfg.MaxPeers), banned) // has to save the private key for host h := &HostV2{ h: p2pHost, diff --git a/p2p/security/security.go b/p2p/security/security.go index db70c76d4..d363a9647 100644 --- a/p2p/security/security.go +++ b/p2p/security/security.go @@ -59,14 +59,14 @@ func (peerMap *peerMap) Range(f func(key string, value []string) bool) { type Manager struct { maxConnPerIP int - maxPeers int64 + maxPeers int mutex sync.Mutex - peers peerMap // All the connected nodes, key is the Peer's IP, value is the peer's ID array + peers *peerMap // All the connected nodes, key is the Peer's IP, value is the peer's ID array banned *blockedpeers.Manager } -func NewManager(maxConnPerIP int, maxPeers int64, banned *blockedpeers.Manager) *Manager { +func NewManager(maxConnPerIP int, maxPeers int, banned *blockedpeers.Manager) *Manager { if maxConnPerIP < 0 { panic("maximum connections per IP must not be negative") }