package shuffling: models -> storage, old storage -> web

This commit is contained in:
Jimmy Zelinskie
2013-10-04 04:19:43 -04:00
parent cf53f9554c
commit 2cd7f0d22f
14 changed files with 264 additions and 262 deletions
+6 -6
View File
@@ -12,7 +12,7 @@ import (
"strconv"
"time"
"github.com/pushrax/chihaya/models"
"github.com/pushrax/chihaya/storage"
)
func (s Server) serveAnnounce(w http.ResponseWriter, r *http.Request) {
@@ -69,7 +69,7 @@ func (s Server) serveAnnounce(w http.ResponseWriter, r *http.Request) {
}
// Create a new peer object from the request
peer := &models.Peer{
peer := &storage.Peer{
ID: peerID,
UserID: user.ID,
TorrentID: torrent.ID,
@@ -82,8 +82,8 @@ func (s Server) serveAnnounce(w http.ResponseWriter, r *http.Request) {
}
// Look for the user in in the pool of seeders and leechers
_, seeder := torrent.Seeders[models.PeerMapKey(peer)]
_, leecher := torrent.Leechers[models.PeerMapKey(peer)]
_, seeder := torrent.Seeders[storage.PeerMapKey(peer)]
_, leecher := torrent.Leechers[storage.PeerMapKey(peer)]
switch {
// Guarantee that no user is in both pools
@@ -318,7 +318,7 @@ func minInt(a, b int) int {
return b
}
func writeSeeders(w http.ResponseWriter, t *models.Torrent, count, numWant int, compact bool) {
func writeSeeders(w http.ResponseWriter, t *storage.Torrent, count, numWant int, compact bool) {
for _, seed := range t.Seeders {
if count >= numWant {
break
@@ -339,7 +339,7 @@ func writeSeeders(w http.ResponseWriter, t *models.Torrent, count, numWant int,
}
}
func writeLeechers(w http.ResponseWriter, t *models.Torrent, count, numWant int, compact bool) {
func writeLeechers(w http.ResponseWriter, t *storage.Torrent, count, numWant int, compact bool) {
for _, leech := range t.Leechers {
if count >= numWant {
break
+2 -2
View File
@@ -11,7 +11,7 @@ import (
"net/http"
"path"
"github.com/pushrax/chihaya/models"
"github.com/pushrax/chihaya/storage"
)
func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request) {
@@ -68,7 +68,7 @@ func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request) {
w.(http.Flusher).Flush()
}
func writeScrapeInfo(w io.Writer, torrent *models.Torrent) {
func writeScrapeInfo(w io.Writer, torrent *storage.Torrent) {
io.WriteString(w, "d")
writeBencoded(w, "complete")
writeBencoded(w, len(torrent.Seeders))
+2 -2
View File
@@ -18,7 +18,7 @@ import (
"time"
"github.com/pushrax/chihaya/config"
"github.com/pushrax/chihaya/models"
"github.com/pushrax/chihaya/storage"
"github.com/pushrax/chihaya/storage/tracker"
)
@@ -133,7 +133,7 @@ func fail(err error, w http.ResponseWriter, r *http.Request) {
w.(http.Flusher).Flush()
}
func validateUser(tx tracker.Conn, dir string) (*models.User, error) {
func validateUser(tx tracker.Conn, dir string) (*storage.User, error) {
if len(dir) != 34 {
return nil, errors.New("Passkey is invalid")
}