downloader

package
v0.0.0-...-8762c42 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkip = fmt.Errorf("skip")
View Source
var Trackers = [][]string{
	trackers.First(7, trackers.Best),
}

Trackers - break down by priority tier

Functions

func AddSegment

func AddSegment(originalFileName, snapDir string, client *torrent.Client) (bool, error)

AddSegment - add existing .seg file, create corresponding .torrent if need

func AddTorrentFile

func AddTorrentFile(torrentFilePath string, torrentClient *torrent.Client) (*torrent.Torrent, error)

AddTorrentFile - adding .torrent file to torrentClient (and checking their hashes), if .torrent file added first time - pieces verification process will start (disk IO heavy) - Progress kept in `piece completion storage` (surviving reboot). Once it done - no disk IO needed again. Don't need call torrent.VerifyData manually

func AllTorrentFiles

func AllTorrentFiles(dir string) ([]string, error)

func AllTorrentPaths

func AllTorrentPaths(dir string) ([]string, error)

func BuildTorrentFilesIfNeed

func BuildTorrentFilesIfNeed(ctx context.Context, snapDir string) ([]string, error)

BuildTorrentFilesIfNeed - create .torrent files from .seg files (big IO) - if .seg files were added manually

func CreateTorrentFileIfNotExists

func CreateTorrentFileIfNotExists(root string, info *metainfo.Info, mi *metainfo.MetaInfo) error

func NewMdbxPieceCompletion

func NewMdbxPieceCompletion(db kv.RwDB) (ret storage.PieceCompletion, err error)

func Proto2InfoHash

func Proto2InfoHash(in *prototypes.H160) metainfo.Hash

func VerifyDtaFiles

func VerifyDtaFiles(ctx context.Context, snapDir string) error

Types

type AggStats

type AggStats struct {
	MetadataReady, FilesTotal int32
	PeersUnique               int32
	ConnectionsTotal          uint64

	Completed bool
	Progress  float32

	BytesCompleted, BytesTotal uint64

	BytesDownload, BytesUpload uint64
	UploadRate, DownloadRate   uint64
}

type Downloader

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

Downloader - component which downloading historical files. Can use BitTorrent, or other protocols

func New

func New(ctx context.Context, cfg *downloadercfg.Cfg) (*Downloader, error)

func (*Downloader) Close

func (d *Downloader) Close()

func (*Downloader) MainLoopInBackground

func (d *Downloader) MainLoopInBackground(ctx context.Context, silent bool)

func (*Downloader) PeerID

func (d *Downloader) PeerID() []byte

func (*Downloader) ReCalcStats

func (d *Downloader) ReCalcStats(interval time.Duration)

func (*Downloader) SnapDir

func (d *Downloader) SnapDir() string

func (*Downloader) Stats

func (d *Downloader) Stats() AggStats

func (*Downloader) StopSeeding

func (d *Downloader) StopSeeding(hash metainfo.Hash) error

func (*Downloader) Torrent

func (d *Downloader) Torrent() *torrent.Client

type GrpcServer

type GrpcServer struct {
	proto_downloader.UnimplementedDownloaderServer
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(d *Downloader) (*GrpcServer, error)

func (*GrpcServer) Download

Download - create new .torrent ONLY if initialSync, everything else Erigon can generate by itself

func (*GrpcServer) Stats

func (*GrpcServer) Verify

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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