Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(network): enabling peer exchange for bootstrappers #778

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions network/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ func newDHTService(ctx context.Context, host lp2phost.Host, protocolID lp2pcore.
opts := []lp2pdht.Option{
lp2pdht.Mode(mode),
lp2pdht.ProtocolPrefix(protocolID),
lp2pdht.DisableProviders(),
lp2pdht.DisableValues(),
lp2pdht.BootstrapPeers(bootsrapAddrs...),
}

Expand Down
12 changes: 10 additions & 2 deletions network/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"context"
"sync"

lp2pps "github.com/libp2p/go-libp2p-pubsub"

Check failure on line 7 in network/gossip.go

View workflow job for this annotation

GitHub Actions / linting

ST1019: package "github.com/libp2p/go-libp2p-pubsub" is being imported more than once (stylecheck)

Check failure on line 7 in network/gossip.go

View workflow job for this annotation

GitHub Actions / build-linux

ST1019: package "github.com/libp2p/go-libp2p-pubsub" is being imported more than once (stylecheck)
pubsub "github.com/libp2p/go-libp2p-pubsub"

Check failure on line 8 in network/gossip.go

View workflow job for this annotation

GitHub Actions / linting

ST1019(related information): other import of "github.com/libp2p/go-libp2p-pubsub" (stylecheck)

Check failure on line 8 in network/gossip.go

View workflow job for this annotation

GitHub Actions / build-linux

ST1019(related information): other import of "github.com/libp2p/go-libp2p-pubsub" (stylecheck)
lp2phost "github.com/libp2p/go-libp2p/core/host"
"github.com/pactus-project/pactus/util/logger"
)
Expand All @@ -21,9 +22,16 @@
}

func newGossipService(ctx context.Context, host lp2phost.Host, eventCh chan Event,
logger *logger.SubLogger,
config *Config, logger *logger.SubLogger,
) *gossipService {
pubsub, err := lp2pps.NewGossipSub(ctx, host)
opts := []pubsub.Option{}

if config.Bootstrapper {
// enable Peer eXchange on bootstrappers
opts = append(opts, lp2pps.WithPeerExchange(true))
}

pubsub, err := lp2pps.NewGossipSub(ctx, host, opts...)
if err != nil {
logger.Panic("unable to start Gossip service", "error", err)
return nil
Expand Down
2 changes: 1 addition & 1 deletion network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func newNetwork(networkName string, conf *Config, opts []lp2p.Option) (*network,

n.dht = newDHTService(n.ctx, n.host, kadProtocolID, conf, n.logger)
n.stream = newStreamService(ctx, n.host, streamProtocolID, relayAddrs, n.eventChannel, n.logger)
n.gossip = newGossipService(ctx, n.host, n.eventChannel, n.logger)
n.gossip = newGossipService(ctx, n.host, n.eventChannel, conf, n.logger)
n.notifee = newNotifeeService(n.host, n.eventChannel, n.logger, streamProtocolID)

n.host.Network().Notify(n.notifee)
Expand Down
Loading