Documentation ¶
Overview ¶
Package bittorrent provides bittorrent related structures
Index ¶
- Constants
- Variables
- type Bitfield
- func (bf *Bitfield) AND(other *Bitfield) *Bitfield
- func (bf *Bitfield) BDecode(r io.Reader) (err error)
- func (bf *Bitfield) BEncode(w io.Writer) (err error)
- func (bf *Bitfield) Completed() bool
- func (bf *Bitfield) Copy() *Bitfield
- func (bf *Bitfield) CopyFrom(other *Bitfield)
- func (bf *Bitfield) CountSet() (sum int)
- func (bf *Bitfield) Equals(other *Bitfield) bool
- func (bf *Bitfield) FindRarest(others []*Bitfield, exclude func(uint32) bool) (idx uint32, has bool)
- func (bf *Bitfield) Has(index uint32) bool
- func (bf *Bitfield) Inverted() (i *Bitfield)
- func (bf Bitfield) MarshalJSON() (data []byte, err error)
- func (bf *Bitfield) OR(other *Bitfield) *Bitfield
- func (bf *Bitfield) Percent() string
- func (bf *Bitfield) Progress() (fl float64)
- func (bf *Bitfield) SelfOR(other *Bitfield)
- func (bf *Bitfield) Set(index uint32)
- func (bf *Bitfield) ToWireMessage() common.WireMessage
- func (bf *Bitfield) UnmarshalJSON(data []byte) (err error)
- func (bf *Bitfield) Unset(index uint32)
- func (bf *Bitfield) XOR(other *Bitfield) *Bitfield
- func (bf *Bitfield) Zero()
- type Handshake
- type Reserved
- type ReservedBit
Constants ¶
View Source
const DHT = ReservedBit(64)
DHT is ReservedBit for BT DHT
View Source
const Extension = ReservedBit(44)
Extension is ReservedBit for bittorrent extensions
Variables ¶
View Source
var ErrInvalidHandshake = errors.New("invalid bittorrent handshake")
ErrInvalidHandshake is returned when a handshake contained invalid format
Functions ¶
This section is empty.
Types ¶
type Bitfield ¶
type Bitfield struct { // length in bits Length uint32 `bencode:"bits"` // bitfield data Data []byte `bencode:"bitfield"` }
Bitfield is a serializable bitmap for bittorrent
func NewBitfield ¶
NewBitfield creates new bitfield given number of bits and initial value
func (*Bitfield) FindRarest ¶
func (bf *Bitfield) FindRarest(others []*Bitfield, exclude func(uint32) bool) (idx uint32, has bool)
FindRarest finds the set bit we have that is rarest in others
func (Bitfield) MarshalJSON ¶
MarshalJSON implements json.Marshaller
func (*Bitfield) ToWireMessage ¶
func (bf *Bitfield) ToWireMessage() common.WireMessage
ToWireMessage serializes to bittorrent wire message
func (*Bitfield) UnmarshalJSON ¶
UnmarshalJSON implements json.Marhsaller
type Handshake ¶
Handshake is a bittorrent protocol handshake info
Directories ¶
Path | Synopsis |
---|---|
swarm package provides compelete bittorrent client that tracks 1 swarm
|
swarm package provides compelete bittorrent client that tracks 1 swarm |
Click to show internal directories.
Click to hide internal directories.