2016-06-01 02:31:50 +08:00
|
|
|
package peerstore
|
2015-10-01 06:42:55 +08:00
|
|
|
|
|
|
|
import (
|
2019-05-31 21:51:16 +08:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
2015-10-01 06:42:55 +08:00
|
|
|
)
|
|
|
|
|
2019-05-31 21:51:16 +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
|
|
|
|
}
|
|
|
|
|
2019-05-31 21:51:16 +08:00
|
|
|
func PeerInfoIDs(pis []peer.AddrInfo) peer.IDSlice {
|
2018-08-31 19:59:46 +08:00
|
|
|
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
|
|
|
|
}
|