storage

package
v0.0.0-...-bcde84c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = func(a ...any) {}

Functions

This section is empty.

Types

type AddUpdate

type AddUpdate struct {
	SessionID int64 `tl:"long"`
	Seqno     int64 `tl:"int"`
	Update    any   `tl:"struct boxed [storage.updateInit,storage.updateHavePieces,storage.updateState]"`
}

type Client

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

func NewClient

func NewClient(dht DHT) *Client

func (*Client) CreateDownloader

func (c *Client) CreateDownloader(ctx context.Context, bagId []byte, desiredMinPeersNum, threadsPerPeer int) (_ TorrentDownloader, err error)

type DHT

type DHT interface {
	StoreAddress(ctx context.Context, addresses address.List, ttl time.Duration, ownerKey ed25519.PrivateKey, copies int) (int, []byte, error)
	FindAddresses(ctx context.Context, key []byte) (*address.List, ed25519.PublicKey, error)
	FindOverlayNodes(ctx context.Context, overlayId []byte, continuation ...*dht.Continuation) (*overlay.NodesList, *dht.Continuation, error)
	Close()
}

type FECInfoNone

type FECInfoNone struct{}

type FileInfo

type FileInfo struct {
	Size            uint64
	FromPiece       uint32
	ToPiece         uint32
	FromPieceOffset uint32
	ToPieceOffset   uint32
}

type GetPiece

type GetPiece struct {
	PieceID int32 `tl:"int"`
}

type GetTorrentInfo

type GetTorrentInfo struct{}

type Ok

type Ok struct{}

type Piece

type Piece struct {
	Proof []byte `tl:"bytes"`
	Data  []byte `tl:"bytes"`
}

type Ping

type Ping struct {
	SessionID int64 `tl:"long"`
}

type Pong

type Pong struct{}

type State

type State struct {
	WillUpload   bool `tl:"bool"`
	WantDownload bool `tl:"bool"`
}

type TorrentDownloader

type TorrentDownloader interface {
	ListFiles() []string
	GetFileOffsets(name string) *FileInfo
	DownloadPiece(ctx context.Context, pieceIndex uint32) (_ []byte, err error)
	SetDesiredMinNodesNum(num int)
	Close()
}

type TorrentHeader

type TorrentHeader struct {
	FilesCount    uint32
	TotalNameSize uint64
	TotalDataSize uint64
	FEC           FECInfoNone
	DirNameSize   uint32
	DirName       []byte
	NameIndex     []uint64
	DataIndex     []uint64
	Names         []byte
	Data          []byte
}

func (*TorrentHeader) Parse

func (t *TorrentHeader) Parse(data []byte) (_ []byte, err error)

func (*TorrentHeader) Serialize

func (t *TorrentHeader) Serialize() ([]byte, error)

type TorrentInfo

type TorrentInfo struct {
	PieceSize  uint32 `tlb:"## 32"`
	FileSize   uint64 `tlb:"## 64"`
	RootHash   []byte `tlb:"bits 256"`
	HeaderSize uint64 `tlb:"## 64"`
	HeaderHash []byte `tlb:"bits 256"`
}

type TorrentInfoContainer

type TorrentInfoContainer struct {
	Data []byte `tl:"bytes"`
}

type UpdateHavePieces

type UpdateHavePieces struct {
	PieceIDs []int32 `tl:"vector int"`
}

type UpdateInit

type UpdateInit struct {
	HavePieces       []byte `tl:"bytes"`
	HavePiecesOffset int32  `tl:"int"`
	State            State  `tl:"struct boxed"`
}

type UpdateState

type UpdateState struct {
	State State `tl:"struct boxed"`
}

Jump to

Keyboard shortcuts

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