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-bitswap
Commits
8c7bf926
Commit
8c7bf926
authored
Mar 25, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: normalize message logging
parent
484399b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
14 deletions
+39
-14
internal/messagequeue/messagequeue.go
internal/messagequeue/messagequeue.go
+25
-5
workers.go
workers.go
+14
-9
No files found.
internal/messagequeue/messagequeue.go
View file @
8c7bf926
...
...
@@ -466,7 +466,7 @@ func (mq *MessageQueue) simulateDontHaveWithTimeout(wantlist []bsmsg.Entry) {
func
(
mq
*
MessageQueue
)
logOutgoingMessage
(
wantlist
[]
bsmsg
.
Entry
)
{
// Save some CPU cycles and allocations if log level is higher than debug
if
ce
:=
sflog
.
Check
(
zap
.
DebugLevel
,
"
Bitswap -> send wants
"
);
ce
==
nil
{
if
ce
:=
sflog
.
Check
(
zap
.
DebugLevel
,
"
sent message
"
);
ce
==
nil
{
return
}
...
...
@@ -474,15 +474,35 @@ func (mq *MessageQueue) logOutgoingMessage(wantlist []bsmsg.Entry) {
for
_
,
e
:=
range
wantlist
{
if
e
.
Cancel
{
if
e
.
WantType
==
pb
.
Message_Wantlist_Have
{
log
.
Debugw
(
"Bitswap -> cancel-have"
,
"local"
,
self
,
"to"
,
mq
.
p
,
"cid"
,
e
.
Cid
)
log
.
Debugw
(
"sent message"
,
"type"
,
"CANCEL_WANT_HAVE"
,
"cid"
,
e
.
Cid
,
"local"
,
self
,
"to"
,
mq
.
p
,
)
}
else
{
log
.
Debugw
(
"Bitswap -> cancel-block"
,
"local"
,
self
,
"to"
,
mq
.
p
,
"cid"
,
e
.
Cid
)
log
.
Debugw
(
"sent message"
,
"type"
,
"CANCEL_WANT_BLOCK"
,
"cid"
,
e
.
Cid
,
"local"
,
self
,
"to"
,
mq
.
p
,
)
}
}
else
{
if
e
.
WantType
==
pb
.
Message_Wantlist_Have
{
log
.
Debugw
(
"Bitswap -> want-have"
,
"local"
,
self
,
"to"
,
mq
.
p
,
"cid"
,
e
.
Cid
)
log
.
Debugw
(
"sent message"
,
"type"
,
"WANT_HAVE"
,
"cid"
,
e
.
Cid
,
"local"
,
self
,
"to"
,
mq
.
p
,
)
}
else
{
log
.
Debugw
(
"Bitswap -> want-block"
,
"local"
,
self
,
"to"
,
mq
.
p
,
"cid"
,
e
.
Cid
)
log
.
Debugw
(
"sent message"
,
"type"
,
"WANT_BLOCK"
,
"cid"
,
e
.
Cid
,
"local"
,
self
,
"to"
,
mq
.
p
,
)
}
}
}
...
...
workers.go
View file @
8c7bf926
...
...
@@ -67,24 +67,28 @@ func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
}
func
(
bs
*
Bitswap
)
logOutgoingBlocks
(
env
*
engine
.
Envelope
)
{
if
ce
:=
sflog
.
Check
(
zap
.
DebugLevel
,
"
Bitswap -> send blocks
"
);
ce
==
nil
{
if
ce
:=
sflog
.
Check
(
zap
.
DebugLevel
,
"
sent message
"
);
ce
==
nil
{
return
}
self
:=
bs
.
network
.
Self
()
for
_
,
blockPresence
:=
range
env
.
Message
.
BlockPresences
()
{
c
:=
blockPresence
.
Cid
switch
blockPresence
.
Type
{
case
pb
.
Message_Have
:
log
.
Debugw
(
"sen
ding
message"
,
log
.
Debugw
(
"sen
t
message"
,
"type"
,
"HAVE"
,
"cid"
,
c
,
"peer"
,
env
.
Peer
,
"local"
,
self
,
"to"
,
env
.
Peer
,
)
case
pb
.
Message_DontHave
:
log
.
Debugw
(
"sen
ding
message"
,
log
.
Debugw
(
"sen
t
message"
,
"type"
,
"DONT_HAVE"
,
"cid"
,
c
,
"peer"
,
env
.
Peer
,
"local"
,
self
,
"to"
,
env
.
Peer
,
)
default
:
panic
(
fmt
.
Sprintf
(
"unrecognized BlockPresence type %v"
,
blockPresence
.
Type
))
...
...
@@ -92,10 +96,11 @@ func (bs *Bitswap) logOutgoingBlocks(env *engine.Envelope) {
}
for
_
,
block
:=
range
env
.
Message
.
Blocks
()
{
log
.
Debugw
(
"sen
ding
message"
,
log
.
Debugw
(
"sen
t
message"
,
"type"
,
"BLOCK"
,
"cid"
,
block
.
Cid
(),
"peer"
,
env
.
Peer
,
"local"
,
self
,
"to"
,
env
.
Peer
,
)
}
}
...
...
@@ -105,8 +110,6 @@ func (bs *Bitswap) sendBlocks(ctx context.Context, env *engine.Envelope) {
// throughout the network stack
defer
env
.
Sent
()
bs
.
logOutgoingBlocks
(
env
)
err
:=
bs
.
network
.
SendMessage
(
ctx
,
env
.
Peer
,
env
.
Message
)
if
err
!=
nil
{
log
.
Debugw
(
"failed to send blocks message"
,
...
...
@@ -116,6 +119,8 @@ func (bs *Bitswap) sendBlocks(ctx context.Context, env *engine.Envelope) {
return
}
bs
.
logOutgoingBlocks
(
env
)
dataSent
:=
0
blocks
:=
env
.
Message
.
Blocks
()
for
_
,
b
:=
range
blocks
{
...
...
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