mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-14 14:58:36 -07:00
Clearer field names for the Tracker struct
This commit is contained in:
@@ -24,7 +24,7 @@ func (t *Tracker) ServeAnnounce(w http.ResponseWriter, r *http.Request, p httpro
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func (t *Tracker) ServeAnnounce(w http.ResponseWriter, r *http.Request, p httpro
|
|||||||
|
|
||||||
if t.cfg.Private {
|
if t.cfg.Private {
|
||||||
delta := models.NewAnnounceDelta(ann, peer, user, torrent, created, snatched)
|
delta := models.NewAnnounceDelta(ann, peer, user, torrent, created, snatched)
|
||||||
err = t.bc.RecordAnnounce(delta)
|
err = t.backend.RecordAnnounce(delta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func TestPrivateAnnounce(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadTestData(tkr *Tracker) error {
|
func loadTestData(tkr *Tracker) error {
|
||||||
conn, err := tkr.tp.Get()
|
conn, err := tkr.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
16
http/api.go
16
http/api.go
@@ -26,7 +26,7 @@ func (t *Tracker) check(w http.ResponseWriter, r *http.Request, p httprouter.Par
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) getTorrent(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
func (t *Tracker) getTorrent(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ func (t *Tracker) putTorrent(w http.ResponseWriter, r *http.Request, p httproute
|
|||||||
return http.StatusBadRequest, err
|
return http.StatusBadRequest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ func (t *Tracker) putTorrent(w http.ResponseWriter, r *http.Request, p httproute
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) delTorrent(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
func (t *Tracker) delTorrent(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ func (t *Tracker) delTorrent(w http.ResponseWriter, r *http.Request, p httproute
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) getUser(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
func (t *Tracker) getUser(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ func (t *Tracker) putUser(w http.ResponseWriter, r *http.Request, p httprouter.P
|
|||||||
return http.StatusBadRequest, err
|
return http.StatusBadRequest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ func (t *Tracker) putUser(w http.ResponseWriter, r *http.Request, p httprouter.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) delUser(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
func (t *Tracker) delUser(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ func (t *Tracker) delUser(w http.ResponseWriter, r *http.Request, p httprouter.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) putClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
func (t *Tracker) putClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ func (t *Tracker) putClient(w http.ResponseWriter, r *http.Request, p httprouter
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) delClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
func (t *Tracker) delClient(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
|
|
||||||
type Tracker struct {
|
type Tracker struct {
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
tp tracker.Pool
|
pool tracker.Pool
|
||||||
bc backend.Conn
|
backend backend.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTracker(cfg *config.Config) (*Tracker, error) {
|
func NewTracker(cfg *config.Config) (*Tracker, error) {
|
||||||
@@ -38,8 +38,8 @@ func NewTracker(cfg *config.Config) (*Tracker, error) {
|
|||||||
|
|
||||||
return &Tracker{
|
return &Tracker{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
tp: tp,
|
pool: tp,
|
||||||
bc: bc,
|
backend: bc,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (t *Tracker) ServeScrape(w http.ResponseWriter, r *http.Request, p httprout
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := t.tp.Get()
|
conn, err := t.pool.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user