boltdbresumer

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package boltdbresumer provides a Resumer implementation that uses a Bolt database file as storage.

Index

Constants

This section is empty.

Variables

View Source
var Keys = struct {
	InfoHash        []byte
	Port            []byte
	Name            []byte
	Trackers        []byte
	URLList         []byte
	FixedPeers      []byte
	Dest            []byte
	Info            []byte
	Bitfield        []byte
	AddedAt         []byte
	BytesDownloaded []byte
	BytesUploaded   []byte
	BytesWasted     []byte
	SeededFor       []byte
	Started         []byte
}{
	InfoHash:        []byte("info_hash"),
	Port:            []byte("port"),
	Name:            []byte("name"),
	Trackers:        []byte("trackers"),
	URLList:         []byte("url_list"),
	FixedPeers:      []byte("fixed_peers"),
	Dest:            []byte("dest"),
	Info:            []byte("info"),
	Bitfield:        []byte("bitfield"),
	AddedAt:         []byte("added_at"),
	BytesDownloaded: []byte("bytes_downloaded"),
	BytesUploaded:   []byte("bytes_uploaded"),
	BytesWasted:     []byte("bytes_wasted"),
	SeededFor:       []byte("seeded_for"),
	Started:         []byte("started"),
}

Keys for the persisten storage.

Functions

This section is empty.

Types

type Resumer

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

Resumer contains methods for saving/loading resume information of a torrent to a BoltDB database.

func New

func New(db *bbolt.DB, bucket []byte) (*Resumer, error)

New returns a new Resumer.

func (*Resumer) Read

func (r *Resumer) Read(torrentID string) (spec *Spec, err error)

func (*Resumer) Write

func (r *Resumer) Write(torrentID string, spec *Spec) error

Write the torrent spec for torrent with `torrentID`.

func (*Resumer) WriteBitfield

func (r *Resumer) WriteBitfield(torrentID string, value []byte) error

WriteBitfield writes only bitfield of a torrent.

func (*Resumer) WriteInfo

func (r *Resumer) WriteInfo(torrentID string, value []byte) error

WriteInfo writes only the info dict of a torrent.

func (*Resumer) WriteStarted added in v0.15.0

func (r *Resumer) WriteStarted(torrentID string, value bool) error

WriteStarted writes the start status of a torrent.

type Spec

type Spec struct {
	InfoHash          []byte
	Port              int
	Name              string
	Trackers          [][]string
	URLList           []string
	FixedPeers        []string
	Info              []byte
	Bitfield          []byte
	AddedAt           time.Time
	BytesDownloaded   int64
	BytesUploaded     int64
	BytesWasted       int64
	SeededFor         time.Duration
	Started           bool
	StopAfterDownload bool
}

Spec contains fields for resuming an existing torrent.

func (Spec) MarshalJSON added in v0.15.0

func (s Spec) MarshalJSON() ([]byte, error)

MarshalJSON converts the Spec to a JSON string.

func (*Spec) UnmarshalJSON added in v0.15.0

func (s *Spec) UnmarshalJSON(b []byte) error

UnmarshalJSON fills the Spec from a JSON string.

Jump to

Keyboard shortcuts

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