Skip to content

Commit

Permalink
Configure libp2p gossipsub WithDirectPeers
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore committed Aug 30, 2023
1 parent b2e6089 commit a7335ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 1 addition & 5 deletions pkg/authn/authn.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,23 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)

if !options.Relay.Disable {
var wakurelayopts []pubsub.Option
wakurelayopts = append(wakurelayopts, pubsub.WithPeerExchange(true))
directPeers := make([]peer.AddrInfo, 0, len(options.StaticNodes))
for _, staticNode := range options.StaticNodes {
ma, err := multiaddr.NewMultiaddr(staticNode)
if err != nil {
s.log.Error("building multiaddr from static node addr", zap.Error(err))
}
pi, err := peer.AddrInfoFromP2pAddr(ma)
if err != nil {
s.log.Error("getting peer addr info from static node addr", zap.Error(err))
}
if pi != nil {
s.log.Error("static node peer addr is nil", zap.String("peer", staticNode))
} else {
directPeers = append(directPeers, *pi)
}
}
wakurelayopts = append(wakurelayopts, pubsub.WithPeerExchange(true), pubsub.WithDirectPeers(directPeers))
nodeOpts = append(nodeOpts, node.WithWakuRelayAndMinPeers(options.Relay.MinRelayPeersToPublish, wakurelayopts...))
}

Expand Down

0 comments on commit a7335ac

Please sign in to comment.