Commit efd006e9 authored by Dirk McCormick's avatar Dirk McCormick

refactor: save some vars

parent e06ac247
...@@ -567,8 +567,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap ...@@ -567,8 +567,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
// Add each regular want-have / want-block to the message // Add each regular want-have / want-block to the message
peerSentCount := 0 peerSentCount := 0
for i := 0; i < len(peerEntries) && msgSize < mq.maxMessageSize; i++ { for ; peerSentCount < len(peerEntries) && msgSize < mq.maxMessageSize; peerSentCount++ {
e := peerEntries[i] e := peerEntries[peerSentCount]
// If the remote peer doesn't support HAVE / DONT_HAVE messages, // If the remote peer doesn't support HAVE / DONT_HAVE messages,
// don't send want-haves (only send want-blocks) // don't send want-haves (only send want-blocks)
if !supportsHave && e.WantType == pb.Message_Wantlist_Have { if !supportsHave && e.WantType == pb.Message_Wantlist_Have {
...@@ -576,13 +576,11 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap ...@@ -576,13 +576,11 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
} else { } else {
msgSize += mq.msg.AddEntry(e.Cid, e.Priority, e.WantType, true) msgSize += mq.msg.AddEntry(e.Cid, e.Priority, e.WantType, true)
} }
peerSentCount++
} }
// Add each broadcast want-have to the message // Add each broadcast want-have to the message
bcstSentCount := 0 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 // Broadcast wants are sent as want-have
wantType := pb.Message_Wantlist_Have wantType := pb.Message_Wantlist_Have
...@@ -592,10 +590,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap ...@@ -592,10 +590,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
wantType = pb.Message_Wantlist_Block wantType = pb.Message_Wantlist_Block
} }
e := bcstEntries[i] e := bcstEntries[bcstSentCount]
msgSize += mq.msg.AddEntry(e.Cid, e.Priority, wantType, false) msgSize += mq.msg.AddEntry(e.Cid, e.Priority, wantType, false)
bcstSentCount++
} }
// Called when the message has been successfully sent. // Called when the message has been successfully sent.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment