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
29161484
Commit
29161484
authored
Mar 18, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(swarm): feed through context
License: MIT Signed-off-by:
Steven Allen
<
steven@stebalien.com
>
parent
597bf2a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
core/commands/swarm.go
core/commands/swarm.go
+7
-6
No files found.
core/commands/swarm.go
View file @
29161484
...
...
@@ -370,7 +370,7 @@ ipfs swarm connect /ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3
addrs
:=
req
.
Arguments
pis, err := peersWithAddresses(addrs)
pis
,
err
:=
peersWithAddresses
(
req
.
Context
,
addrs
)
if
err
!=
nil
{
return
err
}
...
...
@@ -467,9 +467,9 @@ func parseMultiaddrs(maddrs []ma.Multiaddr) (iaddrs []iaddr.IPFSAddr, err error)
// peersWithAddresses is a function that takes in a slice of string peer addresses
// (multiaddr + peerid) and returns a slice of properly constructed peers
func peersWithAddresses(addrs []string) ([]pstore.PeerInfo, error) {
func
peersWithAddresses
(
ctx
context
.
Context
,
addrs
[]
string
)
([]
pstore
.
PeerInfo
,
error
)
{
// resolve addresses
maddrs, err := resolveAddresses(addrs)
maddrs
,
err
:=
resolveAddresses
(
ctx
,
addrs
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -500,7 +500,10 @@ func peersWithAddresses(addrs []string) ([]pstore.PeerInfo, error) {
}
// resolveAddresses resolves addresses parallelly
func resolveAddresses(addrs []string) ([]ma.Multiaddr, error) {
func
resolveAddresses
(
ctx
context
.
Context
,
addrs
[]
string
)
([]
ma
.
Multiaddr
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
dnsResolveTimeout
)
defer
cancel
()
var
maddrs
[]
ma
.
Multiaddr
var
wg
sync
.
WaitGroup
resolveErrC
:=
make
(
chan
error
,
len
(
addrs
))
...
...
@@ -532,9 +535,7 @@ func resolveAddresses(addrs []string) ([]ma.Multiaddr, error) {
wg
.
Add
(
1
)
go
func
(
maddr
ma
.
Multiaddr
)
{
defer
wg
.
Done
()
ctx, cancel := context.WithTimeout(context.Background(), dnsResolveTimeout)
raddrs
,
err
:=
madns
.
Resolve
(
ctx
,
maddr
)
cancel()
if
err
!=
nil
{
resolveErrC
<-
err
return
...
...
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