file

package
v0.0.0-...-0866dc8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultChunkSize represents the default chunk size in bytes.
	DefaultChunkSize = 256

	// DefaultSegmentMaxChunks represents the default maximum number of chunks within a segment.
	DefaultSegmentMaxChunks = 1024

	// DefaultSegmentSize represents the default segment size in bytes.
	DefaultSegmentSize = DefaultChunkSize * DefaultSegmentMaxChunks
)

Variables

View Source
var (
	EmptyChunk     = make([]byte, DefaultChunkSize)
	EmptyChunkHash = crypto.Keccak256Hash(EmptyChunk)
)
View Source
var (
	// ErrFileRequired is returned when manipulate on a folder.
	ErrFileRequired = errors.New("file required")

	// ErrFileEmpty is returned when empty file opened.
	ErrFileEmpty = errors.New("file is empty")
)

Functions

func Exists

func Exists(name string) (bool, error)

Types

type Downloader

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

func NewDownloader

func NewDownloader(clients ...*node.Client) *Downloader

func (*Downloader) Download

func (downloader *Downloader) Download(root, filename string, proof bool) error

type File

type File struct {
	os.FileInfo
	// contains filtered or unexported fields
}

func Open

func Open(name string) (*File, error)

func (*File) Close

func (file *File) Close() error

func (*File) Iterate

func (file *File) Iterate(flowPadding bool) *Iterator

func (*File) MerkleTree

func (file *File) MerkleTree() (*merkle.Tree, error)

func (*File) NumChunks

func (file *File) NumChunks() uint64

func (*File) NumSegments

func (file *File) NumSegments() uint64

type Flow

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

func NewFlow

func NewFlow(file *File, tags []byte) *Flow

func (*Flow) CreateSubmission

func (flow *Flow) CreateSubmission() (*contract.IonianSubmission, error)

type Iterator

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

func NewIterator

func NewIterator(file *os.File, fileSize int64, offset int64, batch int64, flowPadding bool) *Iterator

func NewSegmentIterator

func NewSegmentIterator(file *os.File, fileSize int64, offset int64, flowPadding bool) *Iterator

func (*Iterator) Current

func (it *Iterator) Current() []byte

func (*Iterator) Next

func (it *Iterator) Next() (bool, error)

type SegmentDownloader

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

func NewSegmentDownloader

func NewSegmentDownloader(clients []*node.Client, file *download.DownloadingFile, withProof bool) (*SegmentDownloader, error)

func (*SegmentDownloader) Download

func (downloader *SegmentDownloader) Download() error

Download downloads segments in parallel.

func (*SegmentDownloader) ParallelCollect

func (downloader *SegmentDownloader) ParallelCollect(result *parallel.Result) error

ParallelCollect implements the parallel.Interface interface.

func (*SegmentDownloader) ParallelDo

func (downloader *SegmentDownloader) ParallelDo(routine, task int) (interface{}, error)

ParallelDo implements the parallel.Interface interface.

type UploadOption

type UploadOption struct {
	Tags  []byte // for kv operations
	Force bool   // for kv to upload same file
}

type Uploader

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

func NewUploader

func NewUploader(flow *contract.FlowExt, client *node.Client) *Uploader

func NewUploaderLight

func NewUploaderLight(client *node.Client) *Uploader

func (*Uploader) Upload

func (uploader *Uploader) Upload(filename string, option ...UploadOption) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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