]> Sergey Matveev's repositories - btrtrc.git/blob - peer_protocol/protocol.go
Implement peer connection writer, optimizer and handshake
[btrtrc.git] / peer_protocol / protocol.go
1 package peer_protocol
2
3 type (
4         MessageType byte
5         Integer     uint32
6 )
7
8 const (
9         Protocol = "\x13BitTorrent protocol"
10 )
11
12 const (
13         Choke MessageType = iota
14         Unchoke
15         Interested
16         NotInterested
17         Have
18         Bitfield
19         RequestType
20         Piece
21         Cancel
22 )
23
24 type Request struct {
25         Index, Begin, Length Integer
26 }
27
28 type Message interface {
29         Encode() []byte
30 }
31
32 type Bytes []byte
33
34 func (b Bytes) Encode() []byte {
35         return b
36 }