go-libp2p-core/peerstore/helpers.go
Steven Allen 8c04ed1323
feat: add helper functions for working with addr infos (#202)
Specifically, move them _here_ from the peerstore. That way
packages (like the DHT) that currently directly rely on the peerstore,
can just use go-libp2p-core.

Moved from f7f22569f7/peerstore.go (L79-L93)

With some small modifications.
2021-07-21 13:09:49 -07:00

15 lines
316 B
Go

package peerstore
import (
"github.com/libp2p/go-libp2p-core/peer"
)
// AddrInfos returns an AddrInfo for each specified peer ID, in-order.
func AddrInfos(ps Peerstore, peers []peer.ID) []peer.AddrInfo {
pi := make([]peer.AddrInfo, len(peers))
for i, p := range peers {
pi[i] = ps.PeerInfo(p)
}
return pi
}