<commit_before>package tracker

import (
	"errors"
	"net"
	"net/url"
)

type AnnounceRequest struct {
	InfoHash   [20]byte
	PeerId     [20]byte
	Downloaded int64
	Left       int64
	Uploaded   int64
	Event      AnnounceEvent
	IPAddress  int32
	Key        int32
	NumWant    int32
	Port       int16
}

type AnnounceResponse struct {
	Interval int32
	Leechers int32
	Seeders  int32
	Peers    []Peer
}

type AnnounceEvent int32

type Peer struct {
	IP   net.IP
	Port int
}

const (
	None AnnounceEvent = iota
	Completed
	Started
	Stopped
)

type Client interface {
	Announce(*AnnounceRequest) (AnnounceResponse, error)
	Connect() error
}

var (
	ErrNotConnected = errors.New("not connected")
	ErrBadScheme    = errors.New("unknown scheme")

	schemes = make(map[string]func(*url.URL) Client)
)

func RegisterClientScheme(scheme string, newFunc func(*url.URL) Client) {
	schemes[scheme] = newFunc
}

func New(url *url.URL) (cl Client, err error) {
	newFunc, ok := schemes[url.Scheme]
	if !ok {
		err = ErrBadScheme
		return
	}
	cl = newFunc(url)
	return
}
<commit_msg>Tracker doc<commit_after>package tracker

import (
	"errors"
	"net"
	"net/url"
)

type AnnounceRequest struct {
	InfoHash   [20]byte
	PeerId     [20]byte
	Downloaded int64
	Left       int64
	Uploaded   int64
	Event      AnnounceEvent
	IPAddress  int32
	Key        int32
	NumWant    int32 // How many peer addresses are desired. -1 for default.
	Port       int16
}

type AnnounceResponse struct {
	Interval int32 // Minimum seconds the local peer should wait before next announce.
	Leechers int32
	Seeders  int32
	Peers    []Peer
}

type AnnounceEvent int32

type Peer struct {
	IP   net.IP
	Port int
}

const (
	None      AnnounceEvent = iota
	Completed               // The local peer just completed the torrent.
	Started                 // The local peer has just resumed this torrent.
	Stopped                 // The local peer is leaving the swarm.
)

type Client interface {
	// Returns ErrNotConnected if Connect needs to be called.
	Announce(*AnnounceRequest) (AnnounceResponse, error)
	Connect() error
}

var (
	ErrNotConnected = errors.New("not connected")
	ErrBadScheme    = errors.New("unknown scheme")

	schemes = make(map[string]func(*url.URL) Client)
)

func RegisterClientScheme(scheme string, newFunc func(*url.URL) Client) {
	schemes[scheme] = newFunc
}

func New(url *url.URL) (cl Client, err error) {
	newFunc, ok := schemes[url.Scheme]
	if !ok {
		err = ErrBadScheme
		return
	}
	cl = newFunc(url)
	return
}

{'fraction_non_alphanumeric': 0.08437123342707915, 'fraction_numerical': 0.02129369224588188, 'mean_word_length': 3.213197969543147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1831261', 'n_tokens_mistral': 887, 'n_tokens_neox': 841, 'n_words': 252}