rename *Peers() to PeersWith*().

This commit is contained in:
Raúl Kripalani 2018-09-02 12:18:00 +01:00
parent e200f3a5c1
commit 2f98672d1d
5 changed files with 9 additions and 9 deletions

View File

@ -110,8 +110,8 @@ type AddrBook interface {
// ClearAddresses removes all previously stored addresses
ClearAddrs(p peer.ID)
// AddrsPeers returns all of the peer IDs stored in the AddrBook
AddrsPeers() []peer.ID
// PeersWithAddrs returns all of the peer IDs stored in the AddrBook
PeersWithAddrs() []peer.ID
}
// KeyBook tracks the keys of Peers.
@ -129,6 +129,6 @@ type KeyBook interface {
// AddPrivKey stores the private key of a peer.
AddPrivKey(peer.ID, ic.PrivKey) error
// KeyBookPeers returns all the peer IDs stored in the KeyBook
KeyBookPeers() []peer.ID
// PeersWithKeys returns all the peer IDs stored in the KeyBook
PeersWithKeys() []peer.ID
}

View File

@ -45,7 +45,7 @@ func NewAddrBook() pstore.AddrBook {
}
}
func (mab *memoryAddrBook) AddrsPeers() []peer.ID {
func (mab *memoryAddrBook) PeersWithAddrs() []peer.ID {
mab.addrmu.Lock()
defer mab.addrmu.Unlock()
if mab.addrs == nil {

View File

@ -26,7 +26,7 @@ func NewKeyBook() pstore.KeyBook {
}
}
func (mkb *memoryKeyBook) KeyBookPeers() []peer.ID {
func (mkb *memoryKeyBook) PeersWithKeys() []peer.ID {
mkb.RLock()
ps := make([]peer.ID, 0, len(mkb.pks)+len(mkb.sks))
for p := range mkb.pks {

View File

@ -32,10 +32,10 @@ func NewPeerstoreWith(kb KeyBook, ab AddrBook, md PeerMetadata) Peerstore {
func (ps *peerstore) Peers() []peer.ID {
set := map[peer.ID]struct{}{}
for _, p := range ps.KeyBookPeers() {
for _, p := range ps.PeersWithKeys() {
set[p] = struct{}{}
}
for _, p := range ps.AddrsPeers() {
for _, p := range ps.PeersWithAddrs() {
set[p] = struct{}{}
}

View File

@ -193,7 +193,7 @@ func (mgr *dsAddrBook) Addrs(p peer.ID) []ma.Multiaddr {
}
// Peers returns all of the peer IDs for which the AddrBook has addresses.
func (mgr *dsAddrBook) AddrsPeers() []peer.ID {
func (mgr *dsAddrBook) PeersWithAddrs() []peer.ID {
q := query.Query{KeysOnly: true}
results, err := mgr.ds.Query(q)
if err != nil {