peerstore: AddPeerInfo

This commit is contained in:
Juan Batiz-Benet 2014-12-31 20:33:04 -08:00
parent 57b7903347
commit 1d3554e695
1 changed files with 7 additions and 0 deletions

View File

@ -26,6 +26,9 @@ type Peerstore interface {
// that peer, useful to other services. // that peer, useful to other services.
PeerInfo(ID) PeerInfo PeerInfo(ID) PeerInfo
// AddPeerInfo absorbs the information listed in given PeerInfo.
AddPeerInfo(PeerInfo)
// Get/Put is a simple registry for other peer-related key/value pairs. // Get/Put is a simple registry for other peer-related key/value pairs.
// if we find something we use often, it should become its own set of // if we find something we use often, it should become its own set of
// methods. this is a last resort. // methods. this is a last resort.
@ -235,6 +238,10 @@ func (ps *peerstore) PeerInfo(p ID) PeerInfo {
} }
} }
func (ps *peerstore) AddPeerInfo(pi PeerInfo) {
ps.AddAddresses(pi.ID, pi.Addrs)
}
func PeerInfos(ps Peerstore, peers []ID) []PeerInfo { func PeerInfos(ps Peerstore, peers []ID) []PeerInfo {
pi := make([]PeerInfo, len(peers)) pi := make([]PeerInfo, len(peers))
for i, p := range peers { for i, p := range peers {