[p2p] tuning libp2p parameters to reduce flooding

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3767/merge
Leo Chen 3 years ago
parent cd60f9b6ce
commit 1c450bbc44
  1. 13
      p2p/host.go

@ -9,6 +9,7 @@ import (
"runtime" "runtime"
"strings" "strings"
"sync" "sync"
"time"
"github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p"
libp2p_crypto "github.com/libp2p/go-libp2p-core/crypto" libp2p_crypto "github.com/libp2p/go-libp2p-core/crypto"
@ -153,6 +154,18 @@ func NewHost(cfg HostConfig) (Host, error) {
} }
} }
libp2p_pubsub.GossipSubDlazy = 4
libp2p_pubsub.GossipSubGossipFactor = 0.15
libp2p_pubsub.GossipSubD = 5
libp2p_pubsub.GossipSubDlo = 4
libp2p_pubsub.GossipSubDhi = 8
libp2p_pubsub.GossipSubHistoryLength = 2
libp2p_pubsub.GossipSubHistoryGossip = 2
libp2p_pubsub.GossipSubGossipRetransmission = 2
libp2p_pubsub.GossipSubFanoutTTL = 10 * time.Second
libp2p_pubsub.GossipSubMaxPendingConnections = 32
libp2p_pubsub.GossipSubMaxIHaveLength = 1000
pubsub, err := libp2p_pubsub.NewGossipSub(ctx, p2pHost, options...) pubsub, err := libp2p_pubsub.NewGossipSub(ctx, p2pHost, options...)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "cannot initialize libp2p pub-sub") return nil, errors.Wrapf(err, "cannot initialize libp2p pub-sub")

Loading…
Cancel
Save