rename NewPeerstoreWith(...) => NewPeerstore(...); adjust godoc.

This commit is contained in:
Raúl Kripalani 2018-09-05 15:14:40 +01:00
parent bc77b649dc
commit d79386365e
4 changed files with 8 additions and 7 deletions

View File

@ -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(),
}
}

View File

@ -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) {

View File

@ -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
}

View File

@ -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())