diff --git a/config/config.go b/config/config.go index 12204b6..e94d33b 100644 --- a/config/config.go +++ b/config/config.go @@ -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 ( @@ -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 diff --git a/ipfs/node.go b/ipfs/node.go index abdbd93..74ace45 100644 --- a/ipfs/node.go +++ b/ipfs/node.go @@ -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{