backend

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProgressBarLen = 10
	ScaleBarLen    = 10
)
View Source
const (
	TORRENT = "torrent"

	SEED_PRE = "s-"
)

Variables

View Source
var (
	// ErrInactiveTorrent is for torrent should be actived
	ErrInactiveTorrent = errors.New("torrent is inactive")

	//ErrUnfinished is for the file not downloaded
	ErrUnfinished = errors.New("download not completed")

	ErrTorrentNotFound = errors.New("torrent not found")

	ErrInvalidRawSize = errors.New("invalid raw size")
)

Functions

func GetMessage

func GetMessage(idx int64, units *progress.Units) string

func Hash

func Hash(path string) (ret string, err error)

func IsDirectory

func IsDirectory(path string) (bool, error)

func ProgressBar

func ProgressBar(x, y int64, desc string) string

func ScaleBar

func ScaleBar(from, to, sum int) string

Types

type Torrent

type Torrent struct {
	*torrent.Torrent
	// contains filtered or unexported fields
}

func NewTorrent

func NewTorrent(t *torrent.Torrent, requested int64, ih string, path string, slot int, spec *torrent.TorrentSpec) *Torrent

func (*Torrent) Birth

func (t *Torrent) Birth() mclock.AbsTime

func (*Torrent) BytesRequested

func (t *Torrent) BytesRequested() int64

func (*Torrent) Cited

func (t *Torrent) Cited() int32

func (*Torrent) CitedDec

func (t *Torrent) CitedDec()

func (*Torrent) CitedInc

func (t *Torrent) CitedInc()

func (*Torrent) Close

func (t *Torrent) Close()

func (*Torrent) InfoHash

func (t *Torrent) InfoHash() string

func (*Torrent) IsSeeding

func (t *Torrent) IsSeeding() bool

func (*Torrent) Leech

func (t *Torrent) Leech() error

func (*Torrent) Lock

func (t *Torrent) Lock()

func (*Torrent) Pause

func (t *Torrent) Pause()

func (*Torrent) Paused

func (t *Torrent) Paused() bool

func (*Torrent) Pending

func (t *Torrent) Pending() bool

func (*Torrent) QuotaFull

func (t *Torrent) QuotaFull() bool

func (*Torrent) RLock

func (t *Torrent) RLock()

func (*Torrent) RUnlock

func (t *Torrent) RUnlock()

func (*Torrent) Ready

func (t *Torrent) Ready() bool

func (*Torrent) Running

func (t *Torrent) Running() bool

func (*Torrent) Seed

func (t *Torrent) Seed() bool

func (*Torrent) SetBytesRequested

func (t *Torrent) SetBytesRequested(bytesRequested int64)

func (*Torrent) Spec

func (t *Torrent) Spec() *torrent.TorrentSpec

func (*Torrent) Start

func (t *Torrent) Start() error

func (*Torrent) Status

func (t *Torrent) Status() int

func (*Torrent) Stop

func (t *Torrent) Stop()

func (*Torrent) Stopping

func (t *Torrent) Stopping() bool

func (*Torrent) Unlock

func (t *Torrent) Unlock()

func (*Torrent) WriteTorrent

func (t *Torrent) WriteTorrent() error

type TorrentManager

type TorrentManager struct {

	//boostFetcher        *BoostDataFetcher
	DataDir    string
	TmpDataDir string

	Updates time.Duration
	// contains filtered or unexported fields
}

func NewTorrentManager

func NewTorrentManager(config *params.Config, fsid uint64, cache, compress bool) (*TorrentManager, error)

func (*TorrentManager) AddLocalSeedFile

func (tm *TorrentManager) AddLocalSeedFile(ih string) bool

can only call by fs.go: 'SeedingLocal()'

func (*TorrentManager) Candidate

func (tm *TorrentManager) Candidate() int

func (*TorrentManager) Close

func (tm *TorrentManager) Close() error

func (*TorrentManager) Congress

func (tm *TorrentManager) Congress() int

func (*TorrentManager) Dropping added in v1.0.55

func (tm *TorrentManager) Dropping(ih string) error

func (*TorrentManager) ExistsOrActive added in v1.0.55

func (tm *TorrentManager) ExistsOrActive(ctx context.Context, ih string, rawSize uint64) (bool, uint64, mclock.AbsTime, error)

func (*TorrentManager) GetFile

func (tm *TorrentManager) GetFile(ctx context.Context, infohash, subpath string) (data []byte, err error)

func (*TorrentManager) IsDownloading

func (tm *TorrentManager) IsDownloading(ih string) bool

func (*TorrentManager) IsPending

func (tm *TorrentManager) IsPending(ih string) bool

func (*TorrentManager) IsSeeding

func (tm *TorrentManager) IsSeeding(ih string) bool

func (*TorrentManager) ListAllTorrents

func (tm *TorrentManager) ListAllTorrents() map[string]map[string]int

divide localSeed/on-chain Files return status of torrents

func (*TorrentManager) LocalPort

func (tm *TorrentManager) LocalPort() int

func (*TorrentManager) Metrics

func (tm *TorrentManager) Metrics() time.Duration

func (*TorrentManager) Nominee

func (tm *TorrentManager) Nominee() int

func (*TorrentManager) PauseLocalSeedFile

func (tm *TorrentManager) PauseLocalSeedFile(ih string) error

only files in map:localSeedFile can be paused!

func (*TorrentManager) Pending added in v1.0.55

func (tm *TorrentManager) Pending(t *Torrent)

func (*TorrentManager) ResumeLocalSeedFile

func (tm *TorrentManager) ResumeLocalSeedFile(ih string) error

only files in map:localSeedFile can be resumed!

func (*TorrentManager) Running added in v1.0.55

func (tm *TorrentManager) Running(t *Torrent)

func (*TorrentManager) Search

func (tm *TorrentManager) Search(ctx context.Context, hex string, request uint64) error

Search and donwload files from torrent

func (*TorrentManager) Seeding added in v1.0.55

func (tm *TorrentManager) Seeding(t *Torrent)

func (*TorrentManager) Start

func (tm *TorrentManager) Start() (err error)

Jump to

Keyboard shortcuts

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