Skip to content

Commit

Permalink
config,ipfs: use string
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Dec 1, 2023
1 parent b185904 commit 234d65b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 2 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"
)

type (
Expand Down Expand Up @@ -36,8 +35,8 @@ type (

// IPFSPeer contains the configuration for additional IPFS peers
IPFSPeer struct {
ID peer.ID `yaml:"id"`
Addresses []multiaddr.Multiaddr `yaml:"addresses"`
ID peer.ID `yaml:"id"`
Addresses []string `yaml:"addresses"`
}

// IPFS contains the configuration for the IPFS node
Expand Down
11 changes: 10 additions & 1 deletion ipfs/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,16 @@ func NewNode(ctx context.Context, privateKey crypto.PrivKey, cfg config.IPFS, ds
}

for _, p := range cfg.Peers {
host.Peerstore().AddAddrs(p.ID, p.Addresses, peerstore.PermanentAddrTTL)
mh := make([]multiaddr.Multiaddr, 0, len(p.Addresses))
for _, addr := range p.Addresses {
maddr, err := multiaddr.NewMultiaddr(addr)
if err != nil {
return nil, fmt.Errorf("failed to parse multiaddr %q: %w", addr, err)
}
mh = append(mh, maddr)
}

host.Peerstore().AddAddrs(p.ID, mh, peerstore.PermanentAddrTTL)
}

return &Node{
Expand Down

0 comments on commit 234d65b

Please sign in to comment.