model

package
v0.0.0-...-e0422d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = time.RFC3339

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}
var Data *DB

func Open

func Open(source string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) GetTorrent

func (db *DB) GetTorrent(ID string) (*Torrent, error)

func (*DB) GetTorrentByInfoHash

func (db *DB) GetTorrentByInfoHash(infoHash string) (*Torrent, error)

func (*DB) GetTorrentLog

func (db *DB) GetTorrentLog(infoHash, user string) (*TorrentLog, error)

func (*DB) GetUser

func (db *DB) GetUser(ID string) (*User, error)

func (*DB) Inner

func (db *DB) Inner() *sql.DB

func (*DB) StoreTorrent

func (db *DB) StoreTorrent(t *Torrent) (*Torrent, error)

func (*DB) StoreTorrentLog

func (db *DB) StoreTorrentLog(l *TorrentLog) error

func (*DB) StoreUser

func (db *DB) StoreUser(u *User) (*User, error)

type Torrent

type Torrent struct {
	ID string

	// Owner is the user that contributed the torrent
	Owner string

	// metadata
	Name string
	// TODO: how to implement this in the schema
	// Files     []string
	Category  string
	Freeleech bool

	// TODO: should figure out how to auto-calc this
	Leechers int64
	Seeders  int64

	InfoHash  string
	InfoBytes []byte
}

Torrent is a torrent offered on the tracker

type TorrentLog

type TorrentLog struct {
	ID      int64
	Torrent string // Torrent(InfoHash)
	User    string // User(ID)

	// totals used to determine ratio
	DownloadTotal int64
	UploadTotal   int64

	// rates used to determine if user is
	// seeder or a leecher of the torrent
	DownloadRate int64
	UploadRate   int64
}

type User

type User struct {
	ID        string
	Username  string
	PassHash  string
	IP        net.IP
	IsAdmin   bool
	LastLogin time.Time

	// TODO: should figure out how to auto-calc this
	Uploaded   int64
	Downloaded int64
}

User is a user that has joined the tracker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL