From 90f8cf23a0633a082854912b0bbde4a0b9fd3f89 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 4 Nov 2013 02:41:30 -0500 Subject: [PATCH] storage/tracker docs updated --- storage/storage.go | 9 +++++++-- storage/tracker/tracker.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/storage/storage.go b/storage/storage.go index 3782408..2e1cdb3 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -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"` diff --git a/storage/tracker/tracker.go b/storage/tracker/tracker.go index 33a8fe9..d0a2cf7 100644 --- a/storage/tracker/tracker.go +++ b/storage/tracker/tracker.go @@ -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)