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-kad-dht
Commits
81c8dd93
Commit
81c8dd93
authored
Oct 30, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #241 from jbenet/fix/log-debugf
fix(everything) log.Debug -> log.Debugf
parents
cb144317
a211f1ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
ext_test.go
ext_test.go
+1
-1
query.go
query.go
+10
-10
routing.go
routing.go
+1
-1
No files found.
ext_test.go
View file @
81c8dd93
...
...
@@ -245,7 +245,7 @@ func TestNotFound(t *testing.T) {
ctx
,
_
=
context
.
WithTimeout
(
ctx
,
time
.
Second
*
5
)
v
,
err
:=
d
.
GetValue
(
ctx
,
u
.
Key
(
"hello"
))
log
.
Debug
(
"get value got %v"
,
v
)
log
.
Debug
f
(
"get value got %v"
,
v
)
if
err
!=
nil
{
switch
err
{
case
routing
.
ErrNotFound
:
...
...
query.go
View file @
81c8dd93
...
...
@@ -107,7 +107,7 @@ func newQueryRunner(ctx context.Context, q *dhtQuery) *dhtQueryRunner {
}
func
(
r
*
dhtQueryRunner
)
Run
(
peers
[]
peer
.
Peer
)
(
*
dhtQueryResult
,
error
)
{
log
.
Debug
(
"Run query with %d peers."
,
len
(
peers
))
log
.
Debug
f
(
"Run query with %d peers."
,
len
(
peers
))
if
len
(
peers
)
==
0
{
log
.
Warning
(
"Running query with no peers!"
)
return
nil
,
nil
...
...
@@ -176,7 +176,7 @@ func (r *dhtQueryRunner) addPeerToQuery(next peer.Peer, benchmark peer.Peer) {
r
.
peersSeen
[
next
.
Key
()]
=
next
r
.
Unlock
()
log
.
Debug
(
"adding peer to query: %v
\n
"
,
next
)
log
.
Debug
f
(
"adding peer to query: %v
\n
"
,
next
)
// do this after unlocking to prevent possible deadlocks.
r
.
peersRemaining
.
Increment
(
1
)
...
...
@@ -200,14 +200,14 @@ func (r *dhtQueryRunner) spawnWorkers() {
if
!
more
{
return
// channel closed.
}
log
.
Debug
(
"spawning worker for: %v
\n
"
,
p
)
log
.
Debug
f
(
"spawning worker for: %v
\n
"
,
p
)
go
r
.
queryPeer
(
p
)
}
}
}
func
(
r
*
dhtQueryRunner
)
queryPeer
(
p
peer
.
Peer
)
{
log
.
Debug
(
"spawned worker for: %v
\n
"
,
p
)
log
.
Debug
f
(
"spawned worker for: %v
\n
"
,
p
)
// make sure we rate limit concurrency.
select
{
...
...
@@ -218,12 +218,12 @@ func (r *dhtQueryRunner) queryPeer(p peer.Peer) {
}
// ok let's do this!
log
.
Debug
(
"running worker for: %v"
,
p
)
log
.
Debug
f
(
"running worker for: %v"
,
p
)
// make sure we do this when we exit
defer
func
()
{
// signal we're done proccessing peer p
log
.
Debug
(
"completing worker for: %v"
,
p
)
log
.
Debug
f
(
"completing worker for: %v"
,
p
)
r
.
peersRemaining
.
Decrement
(
1
)
r
.
rateLimit
<-
struct
{}{}
}()
...
...
@@ -232,7 +232,7 @@ func (r *dhtQueryRunner) queryPeer(p peer.Peer) {
// (Incidentally, this will add it to the peerstore too)
err
:=
r
.
query
.
dialer
.
DialPeer
(
p
)
if
err
!=
nil
{
log
.
Debug
(
"ERROR worker for: %v -- err connecting: %v"
,
p
,
err
)
log
.
Debug
f
(
"ERROR worker for: %v -- err connecting: %v"
,
p
,
err
)
r
.
Lock
()
r
.
errs
=
append
(
r
.
errs
,
err
)
r
.
Unlock
()
...
...
@@ -243,20 +243,20 @@ func (r *dhtQueryRunner) queryPeer(p peer.Peer) {
res
,
err
:=
r
.
query
.
qfunc
(
r
.
ctx
,
p
)
if
err
!=
nil
{
log
.
Debug
(
"ERROR worker for: %v %v"
,
p
,
err
)
log
.
Debug
f
(
"ERROR worker for: %v %v"
,
p
,
err
)
r
.
Lock
()
r
.
errs
=
append
(
r
.
errs
,
err
)
r
.
Unlock
()
}
else
if
res
.
success
{
log
.
Debug
(
"SUCCESS worker for: %v"
,
p
,
res
)
log
.
Debug
f
(
"SUCCESS worker for: %v"
,
p
,
res
)
r
.
Lock
()
r
.
result
=
res
r
.
Unlock
()
r
.
cancel
()
// signal to everyone that we're done.
}
else
if
res
.
closerPeers
!=
nil
{
log
.
Debug
(
"PEERS CLOSER -- worker for: %v
\n
"
,
p
)
log
.
Debug
f
(
"PEERS CLOSER -- worker for: %v
\n
"
,
p
)
for
_
,
next
:=
range
res
.
closerPeers
{
r
.
addPeerToQuery
(
next
,
p
)
}
...
...
routing.go
View file @
81c8dd93
...
...
@@ -247,7 +247,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (peer.Peer, error)
return
nil
,
err
}
log
.
Debug
(
"FindPeer %v %v"
,
id
,
result
.
success
)
log
.
Debug
f
(
"FindPeer %v %v"
,
id
,
result
.
success
)
if
result
.
peer
==
nil
{
return
nil
,
routing
.
ErrNotFound
}
...
...
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