From e58fddd264f90675765a98d10534dca772d9f5ec Mon Sep 17 00:00:00 2001 From: MathxH Chen Date: Thu, 2 Sep 2021 00:42:26 +0800 Subject: [PATCH] [p2p] Fix libp2p version lead the consensus issue (#3868) * revert libp2p version * Revert "[p2p] Remove DiscConcurrency code (#3865)" --- go.mod | 6 +++--- p2p/discovery/option.go | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 93abd5ccb..0470d4492 100644 --- a/go.mod +++ b/go.mod @@ -30,12 +30,12 @@ require ( github.com/hashicorp/golang-lru v0.5.4 github.com/ipfs/go-ds-badger v0.2.4 github.com/json-iterator/go v1.1.10 - github.com/libp2p/go-libp2p v0.14.4 + github.com/libp2p/go-libp2p v0.14.0 github.com/libp2p/go-libp2p-core v0.8.6 github.com/libp2p/go-libp2p-crypto v0.1.0 github.com/libp2p/go-libp2p-discovery v0.5.0 - github.com/libp2p/go-libp2p-kad-dht v0.12.2 - github.com/libp2p/go-libp2p-pubsub v0.4.2 + github.com/libp2p/go-libp2p-kad-dht v0.11.1 + github.com/libp2p/go-libp2p-pubsub v0.4.0 github.com/multiformats/go-multiaddr v0.3.3 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/natefinch/lumberjack v2.0.0+incompatible diff --git a/p2p/discovery/option.go b/p2p/discovery/option.go index 74edc1a04..0afe6b8a2 100644 --- a/p2p/discovery/option.go +++ b/p2p/discovery/option.go @@ -34,6 +34,12 @@ func (opt DHTConfig) getLibp2pRawOptions() ([]libp2p_dht.Option, error) { opts = append(opts, dsOption) } + // if Concurrency <= 0, it uses default concurrency supplied from libp2p dht + // the concurrency num meaning you can see Section 2.3 in the KAD paper https://pdos.csail.mit.edu/~petar/papers/maymounkov-kademlia-lncs.pdf + if opt.DiscConcurrency > 0 { + opts = append(opts, libp2p_dht.Concurrency(opt.DiscConcurrency)) + } + return opts, nil }