Skip to content

Commit

Permalink
Merge pull request #534 from yann-y/master
Browse files Browse the repository at this point in the history
feat(retrievalprovider): prioritize announce addresses over host addresses
  • Loading branch information
simlecode authored Jul 25, 2024
2 parents 59102cb + ca2e095 commit 199cfaf
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions retrievalprovider/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ func NewTransportsListener(h host.Host, cfg *config.MarketConfig) (*TransportsLi
var protos []types.Protocol

// Get the libp2p addresses from the Host
if len(h.Addrs()) > 0 {
protos = append(protos, types.Protocol{
Name: "libp2p",
Addresses: h.Addrs(),
})
var maddrs []multiaddr.Multiaddr
switch {
case len(cfg.Libp2p.AnnounceAddresses) > 0:
for i := range cfg.Libp2p.AnnounceAddresses {
maddr, err := multiaddr.NewMultiaddr(cfg.Libp2p.AnnounceAddresses[i])
if err == nil {
maddrs = append(maddrs, maddr)
}
}
case len(h.Addrs()) > 0:
maddrs = h.Addrs()
}
protos = append(protos, types.Protocol{
Name: "libp2p",
Addresses: maddrs,
})

// If there's an http retrieval address specified, add HTTP to the list
// of supported protocols
Expand Down

0 comments on commit 199cfaf

Please sign in to comment.