transfer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 23 Imported by: 2

Documentation

Overview

Package transfer defines data structures and functions for transferring data between local and 0g storage. It contains end-to-end interfaces for uploading and downloading data. These interfaces internally utilize parallelism to leverage computational resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchUploadOption added in v0.5.0

type BatchUploadOption struct {
	Fee         *big.Int       // fee in neuron
	Nonce       *big.Int       // nonce for transaction
	TaskSize    uint           // number of files to upload simutanously
	DataOptions []UploadOption // upload option for single file, nonce and fee are ignored
}

BatchUploadOption upload option for a batching

type Downloader

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

Downloader downloader to download file to storage nodes

func NewDownloader

func NewDownloader(clients []*node.ZgsClient, opts ...zg_common.LogOption) (*Downloader, error)

NewDownloader Initialize a new downloader.

func (*Downloader) Download

func (downloader *Downloader) Download(ctx context.Context, root, filename string, withProof bool) error

Download download data from storage nodes.

type UploadOption

type UploadOption struct {
	Tags             []byte   // transaction tags
	FinalityRequired bool     // wait for file finalized on uploaded nodes or not
	TaskSize         uint     // number of segment to upload in single rpc request
	ExpectedReplica  uint     // expected number of replications
	SkipTx           bool     // skip sending transaction on chain, this can set to true only if the data has already settled on chain before
	Fee              *big.Int // fee in neuron
	Nonce            *big.Int // nonce for transaction
}

UploadOption upload option for a file

type Uploader

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

Uploader uploader to upload file to 0g storage, send on-chain transactions and transfer data to storage nodes.

func NewUploader

func NewUploader(ctx context.Context, flow *contract.FlowContract, clients []*node.ZgsClient, opts ...zg_common.LogOption) (*Uploader, error)

NewUploader Initialize a new uploader.

func (*Uploader) BatchUpload

func (uploader *Uploader) BatchUpload(ctx context.Context, datas []core.IterableData, waitForLogEntry bool, option ...BatchUploadOption) (common.Hash, []common.Hash, error)

BatchUpload submit multiple data to 0g storage contract batchly in single on-chain transaction, then transfer the data to the storage nodes. The nonce for upload transaction will be the first non-nil nonce in given upload options, the protocol fee is the sum of fees in upload options.

func (*Uploader) SubmitLogEntry

func (uploader *Uploader) SubmitLogEntry(ctx context.Context, datas []core.IterableData, tags [][]byte, waitForReceipt bool, nonce *big.Int, fee *big.Int) (common.Hash, *types.Receipt, error)

SubmitLogEntry submit the data to 0g storage contract by sending a transaction

func (*Uploader) Upload

func (uploader *Uploader) Upload(ctx context.Context, data core.IterableData, option ...UploadOption) error

Upload submit data to 0g storage contract, then transfer the data to the storage nodes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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