go-libp2p-peerstore/peerstore.go

23 lines
456 B
Go
Raw Normal View History

2016-06-01 02:31:50 +08:00
package peerstore
2015-10-01 06:42:55 +08:00
import (
"github.com/libp2p/go-libp2p-core/peer"
pstore "github.com/libp2p/go-libp2p-core/peerstore"
2015-10-01 06:42:55 +08:00
)
func PeerInfos(ps pstore.Peerstore, peers peer.IDSlice) []peer.AddrInfo {
pi := make([]peer.AddrInfo, len(peers))
2015-10-01 06:42:55 +08:00
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))
2015-10-01 06:42:55 +08:00
for i, pi := range pis {
ps[i] = pi.ID
}
return ps
}