mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-27 23:40:16 +08:00
rename *Peers() to PeersWith*().
This commit is contained in:
parent
e200f3a5c1
commit
2f98672d1d
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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{}{}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user