a41f938cec
As we have seen, dependencies version can prevent the build. We should user lock versions on dependencies that we know work: * Packages are vendored * Add Godep support * Added addtional install step in readme * Fix travis build error
28 lignes
490 o
Go
28 lignes
490 o
Go
package metainfo
|
|
|
|
import "github.com/anacrolix/missinggo"
|
|
|
|
type Piece struct {
|
|
Info *Info
|
|
i int
|
|
}
|
|
|
|
func (p Piece) Length() int64 {
|
|
if p.i == p.Info.NumPieces()-1 {
|
|
return p.Info.TotalLength() - int64(p.i)*p.Info.PieceLength
|
|
}
|
|
return p.Info.PieceLength
|
|
}
|
|
|
|
func (p Piece) Offset() int64 {
|
|
return int64(p.i) * p.Info.PieceLength
|
|
}
|
|
|
|
func (p Piece) Hash() (ret Hash) {
|
|
missinggo.CopyExact(&ret, p.Info.Pieces[p.i*20:(p.i+1)*20])
|
|
return
|
|
}
|
|
|
|
func (p Piece) Index() int {
|
|
return p.i
|
|
}
|