]> Sergey Matveev's repositories - btrtrc.git/blobdiff - request-strategy/piece.go
Use interfaces to lazily expose the bare minimum inputs to GetRequestablePieces
[btrtrc.git] / request-strategy / piece.go
index 8a038e67dafe8a9ea73531085e6057f0cf500077..626cc75bdb3a12207b8fc94e567562bf758d1036 100644 (file)
@@ -6,19 +6,7 @@ type ChunksIter interface {
        Iter(func(ci ChunkIndex))
 }
 
-type Piece struct {
-       Request           bool
-       Priority          piecePriority
-       Partial           bool
-       Availability      int64
-       Length            int64
-       NumPendingChunks  int
-       IterPendingChunks ChunksIter
-}
-
-func (p Piece) iterPendingChunksWrapper(f func(ChunkIndex)) {
-       i := p.IterPendingChunks
-       if i != nil {
-               i.Iter(f)
-       }
+type Piece interface {
+       Request() bool
+       NumPendingChunks() int
 }