]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Export PiecePriority
authorMatt Joiner <anacrolix@gmail.com>
Wed, 20 Mar 2024 03:37:48 +0000 (14:37 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 20 Mar 2024 03:37:48 +0000 (14:37 +1100)
It's used in some public methods already anyway, so it was a mistake.

file.go
misc.go
piece.go
piecestate.go
requesting.go

diff --git a/file.go b/file.go
index ae802f132c4a5a1e15a377e58c4388067a3a9c40..a71055cfaa6873c98b17704524d2092b05f7ffb8 100644 (file)
--- a/file.go
+++ b/file.go
@@ -18,7 +18,7 @@ type File struct {
        length      int64
        fi          metainfo.FileInfo
        displayPath string
-       prio        piecePriority
+       prio        PiecePriority
        piecesRoot  g.Option[[sha256.Size]byte]
 }
 
@@ -180,7 +180,7 @@ func (f *File) NewReader() Reader {
 }
 
 // Sets the minimum priority for pieces in the File.
-func (f *File) SetPriority(prio piecePriority) {
+func (f *File) SetPriority(prio PiecePriority) {
        f.t.cl.lock()
        if prio != f.prio {
                f.prio = prio
@@ -190,7 +190,7 @@ func (f *File) SetPriority(prio piecePriority) {
 }
 
 // Returns the priority per File.SetPriority.
-func (f *File) Priority() (prio piecePriority) {
+func (f *File) Priority() (prio PiecePriority) {
        f.t.cl.rLock()
        prio = f.prio
        f.t.cl.rUnlock()
diff --git a/misc.go b/misc.go
index 42c516f0ea5568c3a1f1468e0737923fee6e46dc..a76f216f5032082f1e8db606aa8d3fbfedac3645 100644 (file)
--- a/misc.go
+++ b/misc.go
@@ -17,7 +17,7 @@ import (
 type (
        Request       = types.Request
        ChunkSpec     = types.ChunkSpec
-       piecePriority = types.PiecePriority
+       PiecePriority = types.PiecePriority
 )
 
 const (
index 4eec6f28ebca4aa7516a64dadd15c2214518ee01..3ca674d0731af2348476813cf233cce23f42b2c3 100644 (file)
--- a/piece.go
+++ b/piece.go
@@ -31,7 +31,7 @@ type Piece struct {
        storageCompletionOk bool
 
        publicPieceState PieceState
-       priority         piecePriority
+       priority         PiecePriority
        // Availability adjustment for this piece relative to len(Torrent.connsWithAllPieces). This is
        // incremented for any piece a peer has when a peer has a piece, Torrent.haveInfo is true, and
        // the Peer isn't recorded in Torrent.connsWithAllPieces.
@@ -205,14 +205,14 @@ func (p *Piece) torrentEndOffset() int64 {
        return p.torrentBeginOffset() + int64(p.t.usualPieceSize())
 }
 
-func (p *Piece) SetPriority(prio piecePriority) {
+func (p *Piece) SetPriority(prio PiecePriority) {
        p.t.cl.lock()
        defer p.t.cl.unlock()
        p.priority = prio
        p.t.updatePiecePriority(p.index, "Piece.SetPriority")
 }
 
-func (p *Piece) purePriority() (ret piecePriority) {
+func (p *Piece) purePriority() (ret PiecePriority) {
        for _, f := range p.files {
                ret.Raise(f.prio)
        }
index 9e67907bd9b43f332cdfd8c12c4f48a4b1bd40c1..d41f38d9d229bd7487ee2acbf1651a1669048cd6 100644 (file)
@@ -6,7 +6,7 @@ import (
 
 // The current state of a piece.
 type PieceState struct {
-       Priority piecePriority
+       Priority PiecePriority
        storage.Completion
        // The piece is being hashed, or is queued for hash. Deprecated: Use those fields instead.
        Checking bool
index b48fc79f50548a7dcfda61880f4e26e1c9ddc20a..af609356da0c858f1e91739efbd1727e113b1236 100644 (file)
@@ -99,9 +99,9 @@ func (p *desiredPeerRequests) lessByValue(leftRequest, rightRequest RequestIndex
        rightPiece := &p.pieceStates[rightPieceIndex]
        // Putting this first means we can steal requests from lesser-performing peers for our first few
        // new requests.
-       priority := func() piecePriority {
+       priority := func() PiecePriority {
                // Technically we would be happy with the cached priority here, except we don't actually
-               // cache it anymore, and Torrent.piecePriority just does another lookup of *Piece to resolve
+               // cache it anymore, and Torrent.PiecePriority just does another lookup of *Piece to resolve
                // the priority through Piece.purePriority, which is probably slower.
                leftPriority := leftPiece.Priority
                rightPriority := rightPiece.Priority