aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-07-09 15:57:09 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-07-09 15:57:09 +0200
commit7c427cfe24d51feeb8ab7ccc84fc42ba1ad66b3c (patch)
tree416b22e39ab674f43faa2b7130efea1ee383cdb9
parent13b1d4b9a06147cfd1140d42dc6b9ed2ba7a8a90 (diff)
int/int64 stuff
-rw-r--r--meta/info.go12
-rw-r--r--meta/piece.go2
2 files changed, 7 insertions, 7 deletions
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
}