Include completion known in PieceState
This commit is contained in:
parent
de928be582
commit
906d3bc5bb
6
piece.go
6
piece.go
|
@ -229,3 +229,9 @@ func (p *Piece) uncachedPriority() (ret piecePriority) {
|
|||
ret.Raise(p.priority)
|
||||
return
|
||||
}
|
||||
|
||||
func (p *Piece) completion() (ret storage.Completion) {
|
||||
ret.Complete = p.t.pieceComplete(p.index)
|
||||
ret.Ok = p.storageCompletionOk
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package torrent
|
||||
|
||||
import (
|
||||
"github.com/anacrolix/torrent/storage"
|
||||
)
|
||||
|
||||
// The current state of a piece.
|
||||
type PieceState struct {
|
||||
Priority piecePriority
|
||||
// The piece is available in its entirety.
|
||||
Complete bool
|
||||
storage.Completion
|
||||
// The piece is being hashed, or is queued for hash.
|
||||
Checking bool
|
||||
// Some of the piece has been obtained.
|
||||
|
|
|
@ -449,9 +449,7 @@ func (t *Torrent) name() string {
|
|||
func (t *Torrent) pieceState(index int) (ret PieceState) {
|
||||
p := &t.pieces[index]
|
||||
ret.Priority = t.piecePriority(index)
|
||||
if t.pieceComplete(index) {
|
||||
ret.Complete = true
|
||||
}
|
||||
ret.Completion = p.completion()
|
||||
if p.queuedForHash() || p.hashing {
|
||||
ret.Checking = true
|
||||
}
|
||||
|
@ -511,6 +509,8 @@ func pieceStateRunStatusChars(psr PieceStateRun) (ret string) {
|
|||
return "R"
|
||||
case PiecePriorityNow:
|
||||
return "!"
|
||||
case PiecePriorityHigh:
|
||||
return "H"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
@ -524,6 +524,9 @@ func pieceStateRunStatusChars(psr PieceStateRun) (ret string) {
|
|||
if psr.Complete {
|
||||
ret += "C"
|
||||
}
|
||||
if !psr.Ok {
|
||||
ret += "?"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue