-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 https://github.com/libp2p/go-libp2p-peerstore/blob/f7f22569f7d49635953638ffb11915dd3d054cf5/peerstore.go#L79-L93 With some small modifications.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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 | ||
} |