storage/tracker docs updated

This commit is contained in:
Jimmy Zelinskie 2013-11-04 02:41:30 -05:00
parent 2c7fc05c97
commit 90f8cf23a0
2 changed files with 9 additions and 4 deletions

View file

@ -2,14 +2,15 @@
// Use of this source code is governed by the BSD 2-Clause license,
// which can be found in the LICENSE file.
// Package storage implements a high-level abstraction over the multiple
// data stores used by a BitTorrent tracker.
// Package storage implements the models for an abstraction over the
// multiple data stores used by a BitTorrent tracker.
package storage
import (
"strconv"
)
// Peer is the internal representation of a participant in a swarm.
type Peer struct {
ID string `json:"id"`
UserID uint64 `json:"user_id"`
@ -24,10 +25,13 @@ type Peer struct {
LastAnnounce int64 `json:"last_announce"`
}
// PeerMapKey is a helper that returns the proper format for keys used for maps
// of peers (i.e. torrent.Seeders & torrent.Leechers).
func PeerMapKey(peer *Peer) string {
return peer.ID + ":" + strconv.FormatUint(peer.UserID, 36)
}
// Torrent is the internal representation of a swarm for a given torrent file.
type Torrent struct {
ID uint64 `json:"id"`
Infohash string `json:"infohash"`
@ -42,6 +46,7 @@ type Torrent struct {
LastAction int64 `json:"last_action"`
}
// User is the internal representation of registered user for private trackers.
type User struct {
ID uint64 `json:"id"`
Passkey string `json:"passkey"`

View file

@ -3,7 +3,7 @@
// which can be found in the LICENSE file.
// Package tracker provides a generic interface for manipulating a
// BitTorrent tracker's fast-moving, inconsistent data.
// BitTorrent tracker's fast-moving data.
package tracker
import (
@ -55,7 +55,7 @@ type Pool interface {
}
// Conn represents a connection to the data store that can be used
// to make atomic and non-atomic reads/writes.
// to make reads/writes.
type Conn interface {
// Reads
FindUser(passkey string) (*storage.User, bool, error)