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
17d72d8d
Commit
17d72d8d
authored
Aug 02, 2018
by
gpestana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds more and better logging
parent
0073e120
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
Makefile
Makefile
+4
-1
dht.go
dht.go
+10
-7
No files found.
Makefile
View file @
17d72d8d
...
...
@@ -6,4 +6,7 @@ gx:
deps
:
gx
gx
--verbose
install
--global
gx-go rewrite
\ No newline at end of file
gx-go rewrite
publish
:
gx-go rewrite
--undo
dht.go
View file @
17d72d8d
...
...
@@ -150,15 +150,15 @@ func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID,
pmes
.
Record
=
rec
rpmes
,
err
:=
dht
.
sendRequest
(
ctx
,
p
,
pmes
)
if
err
!=
nil
{
if
err
==
ErrReadTimeout
{
log
.
Warningf
(
"read timeout: %s %s"
,
p
.
Pretty
(),
key
)
}
log
.
Warningf
(
"putValueToPeer: %s. (peer: %s, key: %s)"
,
err
.
Error
(),
p
.
Pretty
(),
key
)
return
err
}
if
!
bytes
.
Equal
(
rpmes
.
GetRecord
()
.
Value
,
pmes
.
GetRecord
()
.
Value
)
{
log
.
Warningf
(
"putValueToPeer: value not put correctly. (%v != %v)"
,
pmes
,
rpmes
)
return
errors
.
New
(
"value not put correctly"
)
}
return
nil
}
...
...
@@ -218,7 +218,7 @@ func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID, key string) (
case
nil
:
return
resp
,
nil
case
ErrReadTimeout
:
log
.
Warningf
(
"read timeout
:
%s %s"
,
p
.
Pretty
(),
key
)
log
.
Warningf
(
"
getValueSingle:
read timeout %s %s"
,
p
.
Pretty
(),
key
)
fallthrough
default
:
eip
.
SetError
(
err
)
...
...
@@ -231,12 +231,13 @@ func (dht *IpfsDHT) getLocal(key string) (*recpb.Record, error) {
log
.
Debugf
(
"getLocal %s"
,
key
)
rec
,
err
:=
dht
.
getRecordFromDatastore
(
mkDsKey
(
key
))
if
err
!=
nil
{
log
.
Warningf
(
"getLocal: %v"
,
err
.
Error
())
return
nil
,
err
}
// Double check the key. Can't hurt.
if
rec
!=
nil
&&
rec
.
GetKey
()
!=
key
{
log
.
Errorf
(
"BUG: found a DHT record that didn't match it's key: %s != %s"
,
rec
.
GetKey
(),
key
)
log
.
Errorf
(
"BUG
getLocal
: found a DHT record that didn't match it's key: %s != %s"
,
rec
.
GetKey
(),
key
)
return
nil
,
nil
}
...
...
@@ -256,8 +257,10 @@ func (dht *IpfsDHT) getOwnPrivateKey() (ci.PrivKey, error) {
// putLocal stores the key value pair in the datastore
func
(
dht
*
IpfsDHT
)
putLocal
(
key
string
,
rec
*
recpb
.
Record
)
error
{
log
.
Debugf
(
"putLocal: %v %v"
,
key
,
rec
)
data
,
err
:=
proto
.
Marshal
(
rec
)
if
err
!=
nil
{
log
.
Warningf
(
"putLocal: %v"
,
err
.
Error
())
return
err
}
...
...
@@ -334,7 +337,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [
// no node? nil
if
closer
==
nil
{
log
.
Warning
(
"no closer peers to send:"
,
p
)
log
.
Warning
(
"
betterPeersToQuery:
no closer peers to send:"
,
p
)
return
nil
}
...
...
@@ -343,7 +346,7 @@ func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) [
// == to self? thats bad
if
clp
==
dht
.
self
{
log
.
Warning
(
"
attempted to return self! this shouldn't happen..."
)
log
.
Error
(
"BUG betterPeersToQuery:
attempted to return self! this shouldn't happen..."
)
return
nil
}
// Dont send a peer back themselves
...
...
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