storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(dbnfo DatabaseInfo)

Register appends `databaseinfo` into the map of available drivers.

Types

type Backup

type Backup interface {
	Init(Database) error
	Save() error
	Load() error
}

type BackupInfo

type BackupInfo struct {
	Name string
	Back Backup
}

type Database

type Database interface {
	// Used to init the database after open()
	Init(backup Backup) error

	// Internal functions
	Check() bool
	Backup() Backup
	Trim()
	SyncExpvars() error

	Save(netip.Addr, uint16, bool, Hash, PeerID)
	Drop(Hash, PeerID)

	HashStats(Hash) (uint16, uint16)
	PeerList(Hash, uint, bool) [][]byte
	PeerListBytes(Hash, uint) ([]byte, []byte)

	// Number of hashes for stats
	Hashes() int
}

func Open

func Open() (Database, error)

Open opens and initializes given database type through config.

type DatabaseDriver

type DatabaseDriver struct {
	// contains filtered or unexported fields
}

type DatabaseInfo

type DatabaseInfo struct {
	Name    string
	DB      Database
	Backups []BackupInfo
}

type Hash

type Hash [20]byte

Hash stores a BitTorrent infohash.

type Peer

type Peer struct {
	Complete bool
	IP       netip.Addr
	Port     uint16
	LastSeen int64
}

Peer contains requied peer information for database.

type PeerID

type PeerID [20]byte

PeerID stores a BitTorrent peer ID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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