]> Sergey Matveev's repositories - btrtrc.git/blobdiff - client.go
Change pieceIndex to peer_protocol.Integer
[btrtrc.git] / client.go
index e3182fad0a7487e26ec9d596c2b1125f23a91abd..ecd73b7b54b0b85b1248ea960202acacc8113bef 100644 (file)
--- a/client.go
+++ b/client.go
@@ -18,6 +18,7 @@ import (
        "github.com/anacrolix/dht/krpc"
        "github.com/anacrolix/log"
        "github.com/anacrolix/missinggo"
+       "github.com/anacrolix/missinggo/bitmap"
        "github.com/anacrolix/missinggo/perf"
        "github.com/anacrolix/missinggo/pproffd"
        "github.com/anacrolix/missinggo/pubsub"
@@ -814,7 +815,7 @@ func (cl *Client) sendInitialMessages(conn *connection, torrent *Torrent) {
                if conn.fastEnabled() {
                        if torrent.haveAllPieces() {
                                conn.Post(pp.Message{Type: pp.HaveAll})
-                               conn.sentHaves.AddRange(0, conn.t.NumPieces())
+                               conn.sentHaves.AddRange(0, bitmap.BitIndex(conn.t.NumPieces()))
                                return
                        } else if !torrent.haveAnyPieces() {
                                conn.Post(pp.Message{Type: pp.HaveNone})