From e149a2885dc4afb5a3c5d4729ca31a030351c8ed Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Mon, 15 Jun 2020 10:26:24 +0000 Subject: [PATCH] [p2p] set max pubsub message size to 256Kb Signed-off-by: Leo Chen --- p2p/host.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/p2p/host.go b/p2p/host.go index 51d928fcb..d17a5e219 100644 --- a/p2p/host.go +++ b/p2p/host.go @@ -63,6 +63,11 @@ func (p Peer) String() string { ) } +const ( + // MaxMessageSize is the 2048Kb + MaxMessageSize = 1 << 21 +) + // NewHost .. func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { listenAddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%s", self.Port)) @@ -78,10 +83,9 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) { return nil, errors.Wrapf(err, "cannot initialize libp2p host") } - const MaxSize = 2145728 options := []libp2p_pubsub.Option{ libp2p_pubsub.WithPeerOutboundQueueSize(64), - libp2p_pubsub.WithMaxMessageSize(MaxSize), + libp2p_pubsub.WithMaxMessageSize(MaxMessageSize), } traceFile := os.Getenv("P2P_TRACEFILE")