Move AnnounceResponse and ScrapeResponse to models

This commit is contained in:
Justin Li
2014-07-17 01:10:50 -04:00
parent 3ad3f11b2c
commit 9dde295b7c
6 changed files with 33 additions and 42 deletions
+16
View File
@@ -34,6 +34,8 @@ type Peer struct {
LastAnnounce int64 `json:"last_announce"`
}
type PeerList []Peer
// NewPeer returns the Peer representation of an Announce. When provided nil
// for the announce parameter, it panics. When provided nil for the user or
// torrent parameter, it returns a Peer{UserID: 0} or Peer{TorrentID: 0}
@@ -165,6 +167,15 @@ type AnnounceDelta struct {
Downloaded uint64
}
// AnnounceResponse contains the information needed to fulfill an announce.
type AnnounceResponse struct {
Complete, Incomplete int
Interval, MinInterval time.Duration
IPv4Peers, IPv6Peers PeerList
Compact bool
}
// NewAnnounceDelta calculates a Peer's download and upload deltas between
// Announces and generates an AnnounceDelta.
func NewAnnounceDelta(a *Announce, p *Peer, u *User, t *Torrent, created, snatched bool) *AnnounceDelta {
@@ -206,3 +217,8 @@ type Scrape struct {
Passkey string
Infohashes []string
}
// ScrapeResponse contains the information needed to fulfill a scrape.
type ScrapeResponse struct {
Files []*Torrent
}