Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
e4ffe287
Unverified
Commit
e4ffe287
authored
Feb 14, 2020
by
Janoš Guljaš
Committed by
GitHub
Feb 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dedicated peerstore for every libp2p host (#18)
parent
b5312204
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
go.mod
go.mod
+1
-0
libp2p.go
pkg/p2p/libp2p/libp2p.go
+12
-2
No files found.
go.mod
View file @
e4ffe287
...
...
@@ -11,6 +11,7 @@ require (
github.com/libp2p/go-libp2p v0.5.1
github.com/libp2p/go-libp2p-autonat-svc v0.1.0
github.com/libp2p/go-libp2p-core v0.3.0
github.com/libp2p/go-libp2p-peerstore v0.1.4
github.com/libp2p/go-libp2p-quic-transport v0.2.2
github.com/libp2p/go-libp2p-secio v0.2.1
github.com/libp2p/go-libp2p-tls v0.1.3
...
...
pkg/p2p/libp2p/libp2p.go
View file @
e4ffe287
...
...
@@ -11,8 +11,6 @@ import (
"fmt"
"net"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/ethersphere/bee/pkg/addressbook"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
...
...
@@ -22,10 +20,13 @@ import (
"github.com/libp2p/go-libp2p"
autonat
"github.com/libp2p/go-libp2p-autonat-svc"
crypto
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
libp2ppeer
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
protocol
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
libp2pquic
"github.com/libp2p/go-libp2p-quic-transport"
secio
"github.com/libp2p/go-libp2p-secio"
libp2ptls
"github.com/libp2p/go-libp2p-tls"
...
...
@@ -37,6 +38,7 @@ var _ p2p.Service = (*Service)(nil)
type
Service
struct
{
host
host
.
Host
libp2pPeerstore
peerstore
.
Peerstore
metrics
metrics
networkID
int32
handshakeService
*
handshake
.
Service
...
...
@@ -100,6 +102,8 @@ func New(ctx context.Context, o Options) (*Service, error) {
}
}
libp2pPeerstore
:=
pstoremem
.
NewPeerstore
()
opts
:=
[]
libp2p
.
Option
{
// Multiple listen addresses
libp2p
.
ListenAddrStrings
(
listenAddrs
...
),
...
...
@@ -111,6 +115,8 @@ func New(ctx context.Context, o Options) (*Service, error) {
libp2p
.
DefaultTransports
,
// Attempt to open ports using uPNP for NATed hosts.
libp2p
.
NATPortMap
(),
// Use dedicated peerstore instead the global DefaultPeerstore
libp2p
.
Peerstore
(
libp2pPeerstore
),
}
if
o
.
PrivateKey
!=
nil
{
...
...
@@ -148,6 +154,7 @@ func New(ctx context.Context, o Options) (*Service, error) {
peerRegistry
:=
newPeerRegistry
()
s
:=
&
Service
{
host
:
h
,
libp2pPeerstore
:
libp2pPeerstore
,
metrics
:
newMetrics
(),
networkID
:
o
.
NetworkID
,
handshakeService
:
handshake
.
New
(
peerRegistry
,
o
.
Overlay
,
o
.
NetworkID
,
o
.
Logger
),
...
...
@@ -344,5 +351,8 @@ func (s *Service) newStreamForPeerID(ctx context.Context, peerID libp2ppeer.ID,
}
func
(
s
*
Service
)
Close
()
error
{
if
err
:=
s
.
libp2pPeerstore
.
Close
();
err
!=
nil
{
return
err
}
return
s
.
host
.
Close
()
}
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