mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-27 23:40:16 +08:00
rename NewPeerstoreWith(...) => NewPeerstore(...); adjust godoc.
This commit is contained in:
parent
bc77b649dc
commit
d79386365e
@ -20,12 +20,13 @@ type peerstore struct {
|
||||
protolock sync.Mutex
|
||||
}
|
||||
|
||||
// NewPeerstore creates a threadsafe collection of peers.
|
||||
func NewPeerstoreWith(kb KeyBook, ab AddrBook, md PeerMetadata) Peerstore {
|
||||
// NewPeerstore creates a data structure that stores peer data, backed by the
|
||||
// supplied implementations of KeyBook, AddrBook and PeerMetadata.
|
||||
func NewPeerstore(kb KeyBook, ab AddrBook, md PeerMetadata) Peerstore {
|
||||
return &peerstore{
|
||||
KeyBook: kb,
|
||||
PeerMetadata: md,
|
||||
AddrBook: ab,
|
||||
PeerMetadata: md,
|
||||
Metrics: NewMetrics(),
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ var dsWriteRetries = 5
|
||||
|
||||
var _ pstore.AddrBook = (*dsAddrBook)(nil)
|
||||
|
||||
// dsAddrBook is an address manager backed by a Datastore with both an
|
||||
// dsAddrBook is an address book backed by a Datastore with both an
|
||||
// in-memory TTL manager and an in-memory address stream manager.
|
||||
type dsAddrBook struct {
|
||||
cache *lru.ARCCache
|
||||
@ -33,7 +33,7 @@ type dsAddrBook struct {
|
||||
subsManager *pstoremem.AddrSubManager
|
||||
}
|
||||
|
||||
// NewAddrBook initializes a new address manager given a
|
||||
// NewAddrBook initializes a new address book given a
|
||||
// Datastore instance, a context for managing the TTL manager,
|
||||
// and the interval at which the TTL manager should sweep the Datastore.
|
||||
func NewAddrBook(ctx context.Context, ds ds.Batching, ttlInterval time.Duration) (*dsAddrBook, error) {
|
||||
|
@ -17,6 +17,6 @@ func NewPeerstore(ctx context.Context, ds datastore.Batching) (pstore.Peerstore,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ps := pstore.NewPeerstoreWith(pstoremem.NewKeyBook(), addrBook, pstoremem.NewPeerMetadata())
|
||||
ps := pstore.NewPeerstore(pstoremem.NewKeyBook(), addrBook, pstoremem.NewPeerMetadata())
|
||||
return ps, nil
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import pstore "github.com/libp2p/go-libp2p-peerstore"
|
||||
|
||||
// NewPeerstore creates an in-memory threadsafe collection of peers.
|
||||
func NewPeerstore() pstore.Peerstore {
|
||||
return pstore.NewPeerstoreWith(
|
||||
return pstore.NewPeerstore(
|
||||
NewKeyBook(),
|
||||
NewAddrBook(),
|
||||
NewPeerMetadata())
|
||||
|
Loading…
Reference in New Issue
Block a user