pull/4455/head
frozen 1 year ago
parent 64d7392c3b
commit dc326f6fb2
No known key found for this signature in database
GPG Key ID: 5391C63E79B03EDE
  1. 9
      p2p/host.go
  2. 6
      p2p/security/security.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,

@ -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")
}

Loading…
Cancel
Save