Commit b6a8a73a authored by Dirk McCormick's avatar Dirk McCormick

fix: only mark sent wants as sent

parent 6c412605
...@@ -566,15 +566,16 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap ...@@ -566,15 +566,16 @@ 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 peerSent := make([]wantlist.Entry, 0, len(peerEntries))
for ; peerSentCount < len(peerEntries) && msgSize < mq.maxMessageSize; peerSentCount++ { for i := 0; i < len(peerEntries) && msgSize < mq.maxMessageSize; i++ {
e := peerEntries[peerSentCount] e := peerEntries[i]
// 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 {
mq.peerWants.RemoveType(e.Cid, pb.Message_Wantlist_Have) mq.peerWants.RemoveType(e.Cid, pb.Message_Wantlist_Have)
} else { } else {
msgSize += mq.msg.AddEntry(e.Cid, e.Priority, e.WantType, true) msgSize += mq.msg.AddEntry(e.Cid, e.Priority, e.WantType, true)
peerSent = append(peerSent, e)
} }
} }
...@@ -603,8 +604,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap ...@@ -603,8 +604,8 @@ func (mq *MessageQueue) extractOutgoingMessage(supportsHave bool) (bsmsg.BitSwap
for i := 0; i < bcstSentCount; i++ { for i := 0; i < bcstSentCount; i++ {
mq.bcstWants.MarkSent(bcstEntries[i]) mq.bcstWants.MarkSent(bcstEntries[i])
} }
for i := 0; i < peerSentCount; i++ { for _, e := range peerSent {
mq.peerWants.MarkSent(peerEntries[i]) mq.peerWants.MarkSent(e)
} }
} }
......
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