From 7c427cfe24d51feeb8ab7ccc84fc42ba1ad66b3c Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 9 Jul 2016 15:57:09 +0200 Subject: int/int64 stuff --- meta/info.go | 12 ++++++------ meta/piece.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'meta') diff --git a/meta/info.go b/meta/info.go index c498f9e..a2c23e5 100644 --- a/meta/info.go +++ b/meta/info.go @@ -15,7 +15,7 @@ type Info struct { Length int64 `bencode:"length"` MD5Sum []byte `bencode:"md5sum,optional"` // never seen in wildlife Name string `bencode:"name"` - PieceLength int64 `bencode:"piece length"` + PieceLength int `bencode:"piece length"` Pieces []byte `bencode:"pieces"` // compact mode Private bool `bencode:"private"` // BEP-0027 RootHash []byte `bencode:"root hash"` // BEP-0030 @@ -23,12 +23,12 @@ type Info struct { // Full returns count of full pieces func (i Info) Full() int { - return int(i.TotalLength() / i.PieceLength) + return int(i.TotalLength() / int64(i.PieceLength)) } // Last returns size of last truncated piece -func (i Info) Last() int64 { - return i.TotalLength() % i.PieceLength +func (i Info) Last() int { + return int(i.TotalLength() % int64(i.PieceLength)) } // TotalLength calculates and retuns the length of all files @@ -54,7 +54,7 @@ func (i Info) GetPieces() []Piece { } off := k * sha1.Size copy(p[k].Sum[:], i.Pieces[off:off+sha1.Size]) - p[k].Offset = int64(k) * i.PieceLength + p[k].Offset = int64(k) * int64(i.PieceLength) } return p } @@ -79,7 +79,7 @@ func (i Info) Open(n int) (*os.File, error) { // Offset of piece in gross buffer func (i Info) Offset(piece int) int64 { - return i.PieceLength * int64(piece) + return int64(piece) * int64(i.PieceLength) } // FindFile looks up first file # corresponding to offset into it diff --git a/meta/piece.go b/meta/piece.go index f06c371..a3119e9 100644 --- a/meta/piece.go +++ b/meta/piece.go @@ -4,7 +4,7 @@ import "crypto/sha1" type Piece struct { Offset int64 - Length int64 + Length int Sum [sha1.Size]byte Ok bool } -- cgit v1.2.3