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
dms3
go-dms3
Commits
ccaa490c
Commit
ccaa490c
authored
Oct 16, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better peer gen
parent
e989d6fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
net/swarm/swarm_test.go
net/swarm/swarm_test.go
+7
-9
No files found.
net/swarm/swarm_test.go
View file @
ccaa490c
...
...
@@ -13,7 +13,6 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
)
func
pong
(
ctx
context
.
Context
,
swarm
*
Swarm
)
{
...
...
@@ -30,35 +29,34 @@ func pong(ctx context.Context, swarm *Swarm) {
}
}
func
setupPeer
(
t
*
testing
.
T
,
id
string
,
addr
string
)
*
peer
.
Peer
{
func
setupPeer
(
t
*
testing
.
T
,
addr
string
)
*
peer
.
Peer
{
tcp
,
err
:=
ma
.
NewMultiaddr
(
addr
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
mh
,
err
:=
mh
.
FromHexString
(
id
)
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
512
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
p
:=
&
peer
.
Peer
{
ID
:
peer
.
ID
(
mh
)}
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
512
)
id
,
err
:=
peer
.
IDFromPubKey
(
pk
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
p
:=
&
peer
.
Peer
{
ID
:
id
}
p
.
PrivKey
=
sk
p
.
PubKey
=
pk
p
.
AddAddress
(
tcp
)
return
p
return
p
,
nil
}
func
makeSwarms
(
ctx
context
.
Context
,
t
*
testing
.
T
,
peers
map
[
string
]
string
)
[]
*
Swarm
{
swarms
:=
[]
*
Swarm
{}
for
key
,
addr
:=
range
peers
{
local
:=
setupPeer
(
t
,
key
,
addr
)
local
:=
setupPeer
(
t
,
addr
)
peerstore
:=
peer
.
NewPeerstore
()
swarm
,
err
:=
NewSwarm
(
ctx
,
local
,
peerstore
)
if
err
!=
nil
{
...
...
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