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-routing
Commits
0bad3225
Commit
0bad3225
authored
Nov 10, 2015
by
Juan Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1943 from ipfs/dht/speed
fix swarm dial backoff
parents
51d6f29f
30b4c9e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
dht/query.go
dht/query.go
+16
-2
No files found.
dht/query.go
View file @
0bad3225
...
...
@@ -79,6 +79,8 @@ type dhtQueryRunner struct {
rateLimit
chan
struct
{}
// processing semaphore
log
logging
.
EventLogger
runCtx
context
.
Context
proc
process
.
Process
sync
.
RWMutex
}
...
...
@@ -98,6 +100,7 @@ func newQueryRunner(q *dhtQuery) *dhtQueryRunner {
func
(
r
*
dhtQueryRunner
)
Run
(
ctx
context
.
Context
,
peers
[]
peer
.
ID
)
(
*
dhtQueryResult
,
error
)
{
r
.
log
=
log
r
.
runCtx
=
ctx
if
len
(
peers
)
==
0
{
log
.
Warning
(
"Running query with no peers!"
)
...
...
@@ -167,6 +170,11 @@ func (r *dhtQueryRunner) addPeerToQuery(next peer.ID) {
return
}
notif
.
PublishQueryEvent
(
r
.
runCtx
,
&
notif
.
QueryEvent
{
Type
:
notif
.
AddingPeer
,
ID
:
next
,
})
r
.
peersRemaining
.
Increment
(
1
)
select
{
case
r
.
peersToQuery
.
EnqChan
<-
next
:
...
...
@@ -221,7 +229,12 @@ func (r *dhtQueryRunner) queryPeer(proc process.Process, p peer.ID) {
// make sure we're connected to the peer.
// FIXME abstract away into the network layer
if
conns
:=
r
.
query
.
dht
.
host
.
Network
()
.
ConnsToPeer
(
p
);
len
(
conns
)
==
0
{
log
.
Infof
(
"not connected. dialing."
)
log
.
Error
(
"not connected. dialing."
)
notif
.
PublishQueryEvent
(
r
.
runCtx
,
&
notif
.
QueryEvent
{
Type
:
notif
.
DialingPeer
,
ID
:
p
,
})
// while we dial, we do not take up a rate limit. this is to allow
// forward progress during potentially very high latency dials.
r
.
rateLimit
<-
struct
{}{}
...
...
@@ -231,9 +244,10 @@ func (r *dhtQueryRunner) queryPeer(proc process.Process, p peer.ID) {
if
err
:=
r
.
query
.
dht
.
host
.
Connect
(
ctx
,
pi
);
err
!=
nil
{
log
.
Debugf
(
"Error connecting: %s"
,
err
)
notif
.
PublishQueryEvent
(
c
tx
,
&
notif
.
QueryEvent
{
notif
.
PublishQueryEvent
(
r
.
runC
tx
,
&
notif
.
QueryEvent
{
Type
:
notif
.
QueryError
,
Extra
:
err
.
Error
(),
ID
:
p
,
})
r
.
Lock
()
...
...
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