3 import "github.com/anacrolix/torrent/bencode"
5 // A wrapper around Info that exposes the Bytes directly, in case marshalling
6 // and unmarshalling Info doesn't produce the same bytes.
9 // Set when unmarshalling, and used when marshalling. Call .UpdateBytes to
10 // set it by bencoding Info.
15 _ bencode.Marshaler = &InfoEx{}
16 _ bencode.Unmarshaler = &InfoEx{}
19 // Marshals .Info, and sets .Bytes with the result.
20 func (ie *InfoEx) UpdateBytes() {
22 ie.Bytes, err = bencode.Marshal(&ie.Info)
28 // Returns the SHA1 hash of .Bytes.
29 func (ie *InfoEx) Hash() Hash {
30 return HashBytes(ie.Bytes)
33 func (ie *InfoEx) UnmarshalBencode(data []byte) error {
34 ie.Bytes = append([]byte(nil), data...)
35 return bencode.Unmarshal(data, &ie.Info)
38 func (ie *InfoEx) MarshalBencode() ([]byte, error) {
45 func (info *InfoEx) Piece(i int) Piece {