Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-peerstore
Commits
d7938636
Commit
d7938636
authored
Sep 05, 2018
by
Raúl Kripalani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename NewPeerstoreWith(...) => NewPeerstore(...); adjust godoc.
parent
bc77b649
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
+8
-7
peerstore.go
peerstore.go
+4
-3
pstoreds/addr_book.go
pstoreds/addr_book.go
+2
-2
pstoreds/peerstore.go
pstoreds/peerstore.go
+1
-1
pstoremem/peerstore.go
pstoremem/peerstore.go
+1
-1
No files found.
peerstore.go
View file @
d7938636
...
...
@@ -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
(),
}
}
...
...
pstoreds/addr_book.go
View file @
d7938636
...
...
@@ -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
)
{
...
...
pstoreds/peerstore.go
View file @
d7938636
...
...
@@ -17,6 +17,6 @@ func NewPeerstore(ctx context.Context, ds datastore.Batching) (pstore.Peerstore,
return
nil
,
err
}
ps
:=
pstore
.
NewPeerstore
With
(
pstoremem
.
NewKeyBook
(),
addrBook
,
pstoremem
.
NewPeerMetadata
())
ps
:=
pstore
.
NewPeerstore
(
pstoremem
.
NewKeyBook
(),
addrBook
,
pstoremem
.
NewPeerMetadata
())
return
ps
,
nil
}
pstoremem/peerstore.go
View file @
d7938636
...
...
@@ -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
.
NewPeerstore
With
(
return
pstore
.
NewPeerstore
(
NewKeyBook
(),
NewAddrBook
(),
NewPeerMetadata
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment