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
efd006e9
Commit
efd006e9
authored
Apr 13, 2020
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: save some vars
parent
e06ac247
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
internal/messagequeue/messagequeue.go
internal/messagequeue/messagequeue.go
+4
-8
No files found.
internal/messagequeue/messagequeue.go
View file @
efd006e9
...
...
@@ -567,8 +567,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
// Add each regular want-have / want-block to the message
peerSentCount
:=
0
for
i
:=
0
;
i
<
len
(
peerEntries
)
&&
msgSize
<
mq
.
maxMessageSize
;
i
++
{
e
:=
peerEntries
[
i
]
for
;
peerSentCount
<
len
(
peerEntries
)
&&
msgSize
<
mq
.
maxMessageSize
;
peerSentCount
++
{
e
:=
peerEntries
[
peerSentCount
]
// If the remote peer doesn't support HAVE / DONT_HAVE messages,
// don't send want-haves (only send want-blocks)
if
!
supportsHave
&&
e
.
WantType
==
pb
.
Message_Wantlist_Have
{
...
...
@@ -576,13 +576,11 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
}
else
{
msgSize
+=
mq
.
msg
.
AddEntry
(
e
.
Cid
,
e
.
Priority
,
e
.
WantType
,
true
)
}
peerSentCount
++
}
// Add each broadcast want-have to the message
bcstSentCount
:=
0
for
i
:=
0
;
i
<
len
(
bcstEntries
)
&&
msgSize
<
mq
.
maxMessageSize
;
i
++
{
for
;
bcstSentCount
<
len
(
bcstEntries
)
&&
msgSize
<
mq
.
maxMessageSize
;
bcstSentCount
++
{
// Broadcast wants are sent as want-have
wantType
:=
pb
.
Message_Wantlist_Have
...
...
@@ -592,10 +590,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
wantType
=
pb
.
Message_Wantlist_Block
}
e
:=
bcstEntries
[
i
]
e
:=
bcstEntries
[
bcstSentCount
]
msgSize
+=
mq
.
msg
.
AddEntry
(
e
.
Cid
,
e
.
Priority
,
wantType
,
false
)
bcstSentCount
++
}
// Called when the message has been successfully sent.
...
...
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