aboutsummaryrefslogtreecommitdiff
path: root/meta/piece.go
blob: 58b87af5d1e984cf5c15967c7e8d77024612e863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package meta

import "crypto/sha1"

type Piece struct {
	Offset int
	Length int
	Sum    [sha1.Size]byte
}

func (p Piece) Check(b []byte) bool {
	return sha1.Sum(b) == p.Sum
}

func (p Piece) Size() int {
	return p.Length
}