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-swarm
Commits
9515c73f
Unverified
Commit
9515c73f
authored
Nov 11, 2016
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update for changed libp2p-conn
parent
5d1bbd52
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
9 deletions
+15
-9
package.json
package.json
+1
-1
swarm.go
swarm.go
+9
-3
swarm_addr_test.go
swarm_addr_test.go
+2
-2
swarm_listen.go
swarm_listen.go
+1
-1
swarm_net.go
swarm_net.go
+1
-1
swarm_net_test.go
swarm_net_test.go
+1
-1
No files found.
package.json
View file @
9515c73f
...
...
@@ -81,7 +81,7 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
U1YMnktAuCPBC7TqhbZRkpZ7KCiekv7SZtaLU5zpTgqb
"
,
"hash"
:
"Qm
RJA93XFXJTVqFgC1mquPV4m1MkNrtTsfnRmFUy4Mhoih
"
,
"name"
:
"go-libp2p-conn"
,
"version"
:
"1.4.0"
},
...
...
swarm.go
View file @
9515c73f
...
...
@@ -103,8 +103,13 @@ type Swarm struct {
protec
ipnet
.
Protector
}
// NewSwarm constructs a Swarm, with a Chan.
func
NewSwarm
(
ctx
context
.
Context
,
listenAddrs
[]
ma
.
Multiaddr
,
local
peer
.
ID
,
peers
pstore
.
Peerstore
,
bwc
metrics
.
Reporter
)
(
*
Swarm
,
error
)
{
return
NewSwarmWithProtector
(
ctx
,
listenAddrs
,
local
,
peers
,
nil
,
bwc
)
}
// NewSwarm constructs a Swarm, with a Chan.
func
NewSwarmWithProtector
(
ctx
context
.
Context
,
listenAddrs
[]
ma
.
Multiaddr
,
local
peer
.
ID
,
peers
pstore
.
Peerstore
,
protec
ipnet
.
Protector
,
bwc
metrics
.
Reporter
)
(
*
Swarm
,
error
)
{
listenAddrs
,
err
:=
filterAddrs
(
listenAddrs
)
...
...
@@ -133,9 +138,10 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, local peer.ID,
bwc
:
bwc
,
fdRateLimit
:
make
(
chan
struct
{},
concurrentFdDials
),
Filters
:
filter
.
NewFilters
(),
dialer
:
conn
.
NewDialer
(
local
,
peers
.
PrivKey
(
local
),
protec
,
wrap
),
dialer
:
conn
.
NewDialer
(
local
,
peers
.
PrivKey
(
local
),
wrap
),
protec
:
protec
,
}
s
.
dialer
.
Protector
=
protec
s
.
dsync
=
NewDialSync
(
s
.
doDial
)
s
.
limiter
=
newDialLimiter
(
s
.
dialAddr
)
...
...
@@ -162,7 +168,7 @@ func NewBlankSwarm(ctx context.Context, id peer.ID, privkey ci.PrivKey, pstpt ps
notifs
:
make
(
map
[
inet
.
Notifiee
]
ps
.
Notifiee
),
fdRateLimit
:
make
(
chan
struct
{},
concurrentFdDials
),
Filters
:
filter
.
NewFilters
(),
dialer
:
conn
.
NewDialer
(
id
,
privkey
,
nil
,
nil
),
dialer
:
conn
.
NewDialer
(
id
,
privkey
,
nil
),
}
// configure Swarm
...
...
swarm_addr_test.go
View file @
9515c73f
...
...
@@ -65,11 +65,11 @@ func TestFilterAddrs(t *testing.T) {
ps
:=
pstore
.
NewPeerstore
()
ctx
:=
context
.
Background
()
if
_
,
err
:=
NewNetwork
(
ctx
,
bad
,
id
,
ps
,
metrics
.
NewBandwidthCounter
());
err
==
nil
{
if
_
,
err
:=
NewNetwork
(
ctx
,
bad
,
id
,
ps
,
nil
,
metrics
.
NewBandwidthCounter
());
err
==
nil
{
t
.
Fatal
(
"should have failed to create swarm"
)
}
if
_
,
err
:=
NewNetwork
(
ctx
,
goodAndBad
,
id
,
ps
,
metrics
.
NewBandwidthCounter
());
err
!=
nil
{
if
_
,
err
:=
NewNetwork
(
ctx
,
goodAndBad
,
id
,
ps
,
nil
,
metrics
.
NewBandwidthCounter
());
err
!=
nil
{
t
.
Fatal
(
"should have succeeded in creating swarm"
,
err
)
}
}
...
...
swarm_listen.go
View file @
9515c73f
...
...
@@ -83,7 +83,7 @@ func (s *Swarm) addListener(tptlist transport.Listener) error {
log
.
Warning
(
"Listener not given PrivateKey, so WILL NOT SECURE conns."
)
}
list
,
err
:=
conn
.
WrapTransportListener
(
s
.
Context
(),
tptlist
,
s
.
local
,
sk
,
s
.
protec
)
list
,
err
:=
conn
.
WrapTransportListener
WithProtector
(
s
.
Context
(),
tptlist
,
s
.
local
,
sk
,
s
.
protec
)
if
err
!=
nil
{
return
err
}
...
...
swarm_net.go
View file @
9515c73f
...
...
@@ -22,7 +22,7 @@ type Network Swarm
func
NewNetwork
(
ctx
context
.
Context
,
listen
[]
ma
.
Multiaddr
,
local
peer
.
ID
,
peers
pstore
.
Peerstore
,
protec
ipnet
.
Protector
,
bwc
metrics
.
Reporter
)
(
*
Network
,
error
)
{
s
,
err
:=
NewSwarm
(
ctx
,
listen
,
local
,
peers
,
protec
,
bwc
)
s
,
err
:=
NewSwarm
WithProtector
(
ctx
,
listen
,
local
,
peers
,
protec
,
bwc
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
swarm_net_test.go
View file @
9515c73f
...
...
@@ -17,7 +17,7 @@ func GenSwarmNetwork(t *testing.T, ctx context.Context) *Network {
ps
:=
pstore
.
NewPeerstore
()
ps
.
AddPubKey
(
p
.
ID
,
p
.
PubKey
)
ps
.
AddPrivKey
(
p
.
ID
,
p
.
PrivKey
)
n
,
err
:=
NewNetwork
(
ctx
,
[]
ma
.
Multiaddr
{
p
.
Addr
},
p
.
ID
,
ps
,
nil
)
n
,
err
:=
NewNetwork
(
ctx
,
[]
ma
.
Multiaddr
{
p
.
Addr
},
p
.
ID
,
ps
,
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
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