ceremonyclient/go-libp2p/p2p/host/peerstore/peerstore.go

23 lines
456 B
Go
Raw Normal View History

2023-08-21 03:50:38 +00:00
package peerstore
import (
"github.com/libp2p/go-libp2p/core/peer"
pstore "github.com/libp2p/go-libp2p/core/peerstore"
)
func PeerInfos(ps pstore.Peerstore, peers peer.IDSlice) []peer.AddrInfo {
pi := make([]peer.AddrInfo, len(peers))
for i, p := range peers {
pi[i] = ps.PeerInfo(p)
}
return pi
}
func PeerInfoIDs(pis []peer.AddrInfo) peer.IDSlice {
ps := make(peer.IDSlice, len(pis))
for i, pi := range pis {
ps[i] = pi.ID
}
return ps
}