sdk

package
v1.18.0-RC11 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 70 Imported by: 13

Documentation

Overview

Main functionality of the SDK.

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
)
View Source
const (
	CanUploadMask = uint16(1)  // 0000 0001
	CanDeleteMask = uint16(2)  // 0000 0010
	CanUpdateMask = uint16(4)  // 0000 0100
	CanMoveMask   = uint16(8)  // 0000 1000
	CanCopyMask   = uint16(16) // 0001 0000
	CanRenameMask = uint16(32) // 0010 0000
)
View Source
const (
	LockExists     = "lock_exists"
	RateLimitError = "rate_limit_error"
)
View Source
const (
	// EncryptedDataPaddingSize additional bytes to save encrypted data
	EncryptedDataPaddingSize = 16
	// EncryptionHeaderSize encryption header size in chunk: PRE.MessageChecksum(128)+PRE.OverallChecksum(128)
	EncryptionHeaderSize = 128 + 128
	// ReEncryptionHeaderSize re-encryption header size in chunk
	ReEncryptionHeaderSize = 256
)
View Source
const (
	DOWNLOAD_CONTENT_FULL  = "full"
	DOWNLOAD_CONTENT_THUMB = "thumbnail"
)
View Source
const (
	DefaultCreateConnectionTimeOut = 45 * time.Second
	StorageV2                      = 1
)
View Source
const (
	// EncryptionOverHead File size increases by 16 bytes after encryption. Two checksums i.e. MessageChecksum and OverallChecksum has
	// 128 bytes size each.
	// So total overhead for each encrypted data is 16 + 128*2 = 272
	EncryptionOverHead = 272
	ChecksumSize       = 256
	HeaderSize         = 128
	BlockSize          = 64 * KB
)
View Source
const (
	NotEnoughTokens              = "not_enough_tokens"
	InvalidAuthTicket            = "invalid_authticket"
	InvalidShare                 = "invalid_share"
	InvalidRead                  = "invalid_read"
	ExceededMaxOffsetValue       = "exceeded_max_offset_value"
	NegativeOffsetResultantValue = "negative_offset_resultant_value"
	InvalidWhenceValue           = "invalid_whence_value"
)

error codes

View Source
const (
	OpUpload   int = 0
	OpDownload int = 1
	OpRepair   int = 2
	OpUpdate   int = 3
)
View Source
const (
	// Upload - Upload file to remote
	Upload = "Upload"

	// Download - Download file from remote
	Download = "Download"

	// Update - Update file in remote
	Update = "Update"

	// Delete - Delete file from remote
	Delete = "Delete"

	// Conflict - Conflict in file
	Conflict = "Conflict"

	// LocalDelete - Delete file from local
	LocalDelete = "LocalDelete"
)

For sync app

View Source
const (
	// BlocksFor10MB is number of blocks required for to make 10MB data.
	// It is simply calculated as 10MB / 64KB = 160
	// If blobber cannot respond with 10MB data then client can use numBlocks field
	// in StreamDownload struct
	BlocksFor10MB = 160
)
View Source
const CHUNK_SIZE = 64 * 1024
View Source
const DefaultBlocksPerMarker int = 100
View Source
const DefaultChunkSize = 64 * 1024

DefaultChunkSize default chunk size for file and thumbnail

View Source
const (
	DefaultUploadTimeOut = 180 * time.Second
)
View Source
const (
	DirectoryExists = "directory_exists"
)
View Source
const INVALID_PATH = "invalid_path"
View Source
const MARKER_VERSION = "v2"
View Source
const MAX_BLOCKS = 80 // 5MB(CHUNK_SIZE*80)
View Source
const MINERSC_SCADDRESS = "6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9"
View Source
const STORAGE_SCADDRESS = "6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7"
View Source
const SignatureV2 = 1
View Source
const WMLockWaitTime = 2 * time.Second
View Source
const ZCNSC_SCADDRESS = "6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712e0"

Variables

View Source
var (
	IsWasm           = false
	MultiOpBatchSize = 50
	RepairBatchSize  = 50
	Workdir          string
)
View Source
var (
	CmdFFmpeg = "ffmpeg"
	// DefaultHashFunc default hash method for stream merkle tree
	DefaultHashFunc = func(left, right string) string {
		return coreEncryption.Hash(left + right)
	}

	ErrInvalidChunkSize              = errors.New("chunk: chunk size is too small. it must greater than 272 if file is uploaded with encryption")
	ErrNoEnoughSpaceLeftInAllocation = errors.New("alloc: no enough space left in allocation")
	CancelOpCtx                      = make(map[string]context.CancelCauseFunc)

	CurrentMode = UploadModeMedium

	HighModeWorkers = 4
)
View Source
var (
	ErrRetryOperation = errors.New("retry_operation")
	ErrRepairRequired = errors.New("repair_required")
	ErrNetwork        = errors.New("network_error")
)
View Source
var BatchSize = 6
View Source
var (
	// ErrClispIsNotReady clips file is not ready
	ErrClispIsNotReady = errors.New("live: clips is not ready")
)
View Source
var ErrFileNameTooLong = errors.New("invalid_parameter", "filename is longer than 150 characters")
View Source
var ErrInvalidPrivateShare = errors.New("invalid_private_share", "private sharing is only available for encrypted file")
View Source
var ErrInvalidRead = errors.New(InvalidRead, "want_size is <= 0")

errors

View Source
var ErrPauseUpload = errors.New("upload paused by user")
View Source
var GetFileInfo = func(localpath string) (os.FileInfo, error) {
	return sys.Files.Stat(localpath)
}
View Source
var RepairBlocks = 100

Functions

func AddBlockDownloadReq

func AddBlockDownloadReq(ctx context.Context, req *BlockDownloadRequest, rb zboxutil.DownloadBuffer, effectiveBlockSize int)

func AddCommitRequest

func AddCommitRequest(req CommitRequestInterface)

func AddFreeStorageAssigner

func AddFreeStorageAssigner(name, publicKey string, individualLimit, totalLimit float64) (string, int64, error)

AddFreeStorageAssigner adds a new free storage assigner (txn: `storagesc.add_free_allocation_assigner`). The free storage assigner is used to create free allocations. Can only be called by chain owner.

  • name is the name of the assigner.
  • publicKey is the public key of the assigner.
  • individualLimit is the individual limit of the assigner for a single free allocation request
  • totalLimit is the total limit of the assigner for all free allocation requests.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func CancelAllocation

func CancelAllocation(allocID string) (hash string, nonce int64, err error)

CancelAllocation sends a cancel request for an allocation (txn: `storagesc.cancel_allocation`)

  • allocID is the id of the allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func CollectRewards added in v1.7.1

func CollectRewards(providerId string, providerType ProviderType) (string, int64, error)

CollectRewards collects the rewards for a provider (txn: `storagesc.collect_reward`)

  • providerId is the id of the provider.
  • providerType is the type of the provider.

func CommitToFabric

func CommitToFabric(metaTxnData, fabricConfigJSON string) (string, error)

func CreateAllocationForOwner

func CreateAllocationForOwner(
	owner, ownerpublickey string,
	datashards, parityshards int, size int64,
	readPrice, writePrice PriceRange,
	lock uint64, preferredBlobberIds, blobberAuthTickets []string, thirdPartyExtendable, IsEnterprise, force bool, fileOptionsParams *FileOptionsParameters,
) (hash string, nonce int64, txn *transaction.Transaction, err error)

CreateAllocationForOwner creates a new allocation with the given options (txn: `storagesc.new_allocation_request`).

  • owner is the client id of the owner of the allocation.
  • ownerpublickey is the public key of the owner of the allocation.
  • datashards is the number of data shards for the allocation.
  • parityshards is the number of parity shards for the allocation.
  • size is the size of the allocation.
  • readPrice is the read price range for the allocation (Reads in Züs are free!).
  • writePrice is the write price range for the allocation.
  • lock is the lock value for the transaction (how much tokens to lock to the allocation, in SAS).
  • preferredBlobberIds is a list of preferred blobber ids for the allocation.
  • thirdPartyExtendable is a flag indicating whether the allocation can be extended by a third party.
  • fileOptionsParams is the file options parameters for the allocation, which control the usage permissions of the files in the allocation.

returns the hash of the transaction, the nonce of the transaction, the transaction object and an error if any.

func CreateAllocationWith added in v1.8.7

func CreateAllocationWith(options CreateAllocationOptions) (
	string, int64, *transaction.Transaction, error)

CreateAllocationWith creates a new allocation with the given options for the current client using the SDK. Similar ro CreateAllocationForOwner but uses an options struct instead of individual parameters.

  • options is the options struct instance for creating the allocation.

returns the hash of the new_allocation_request transaction, the nonce of the transaction, the transaction object and an error if any.

func CreateFreeAllocation

func CreateFreeAllocation(marker string, value uint64) (string, int64, error)

CreateFreeAllocation creates a new free allocation (txn: `storagesc.free_allocation_request`).

  • marker is the marker for the free allocation.
  • value is the value of the free allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func FinalizeAllocation

func FinalizeAllocation(allocID string) (hash string, nonce int64, err error)

FinalizeAllocation sends a finalize request for an allocation (txn: `storagesc.finalize_allocation`)

  • allocID is the id of the allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func GenerateParentPaths added in v1.8.17

func GenerateParentPaths(path string) map[string]bool

GenerateParentPath generates the parent path of the given path.

  • path: the path to generate the parent path from.

func GetAllocationBlobbers added in v1.8.6

func GetAllocationBlobbers(
	storageVersion, datashards, parityshards int,
	size int64,
	isRestricted int,
	readPrice, writePrice PriceRange,
	force ...bool,
) ([]string, error)

GetAllocationBlobbers returns a list of blobber ids that can be used for a new allocation.

  • datashards is the number of data shards for the allocation.
  • parityshards is the number of parity shards for the allocation.
  • size is the size of the allocation.
  • readPrice is the read price range for the allocation (Reads in Züs are free!).
  • writePrice is the write price range for the allocation.
  • force is a flag indicating whether to force the allocation to be created.

returns the list of blobber ids and an error if any.

func GetAllocationMinLock

func GetAllocationMinLock(
	datashards, parityshards int,
	size int64,
	writePrice PriceRange,
) (int64, error)

GetAllocationMinLock calculates and returns the minimum lock demand for creating a new allocation, which represents the cost of the creation process.

  • datashards is the number of data shards for the allocation.
  • parityshards is the number of parity shards for the allocation.
  • size is the size of the allocation.
  • writePrice is the write price range for the allocation.

returns the minimum lock demand for the creation process and an error if any.

func GetAllocationUpdates added in v1.4.0

func GetAllocationUpdates(allocation *Allocation) error

func GetBlobberIds added in v1.8.6

func GetBlobberIds(blobberUrls []string) ([]string, error)

GetBlobberIds returns a list of blobber ids that can be used for a new allocation.

  • blobberUrls is a list of blobber urls.

returns a list of blobber ids that can be used for the new allocation and an error if any.

func GetClientEncryptedPublicKey

func GetClientEncryptedPublicKey() (string, error)

GetClientEncryptedPublicKey - get the client's public key

func GetDStorageFileReader added in v1.8.16

func GetDStorageFileReader(alloc *Allocation, ref *ORef, sdo *StreamDownloadOption) (io.ReadSeekCloser, error)

GetDStorageFileReader will initialize erasure decoder, decrypter if file is encrypted and other necessary fields and returns a reader that comply with io.ReadSeekCloser interface.

func GetFileRefFromBlobber added in v1.8.17

func GetFileRefFromBlobber(allocationID, blobberId, remotePath string) (fRef *fileref.FileRef, err error)

func GetFreeAllocationBlobbers added in v1.12.1

func GetFreeAllocationBlobbers(request map[string]interface{}) ([]string, error)

GetFreeAllocationBlobbers returns a list of blobber ids that can be used for a new free allocation.

  • request is the request data for the free allocation.

returns a list of blobber ids that can be used for the new free allocation and an error if any.

func GetLogger

func GetLogger() *logger.Logger

GetLogger retrieves logger instance

func GetMptData added in v1.2.82

func GetMptData(key string) ([]byte, error)

GetMptData retrieves mpt key data.

func GetTranscodeFile added in v1.11.0

func GetTranscodeFile(remotePath string) (string, string)

func GetUpdateAllocationMinLock added in v1.8.17

func GetUpdateAllocationMinLock(
	allocationID string,
	size int64,
	extend bool,
	addBlobberId,
	removeBlobberId string) (int64, error)

GetUpdateAllocationMinLock returns the minimum lock demand for updating an allocation, which represents the cost of the update operation.

  • allocationID is the id of the allocation.
  • size is the new size of the allocation.
  • extend is a flag indicating whether to extend the expiry of the allocation.
  • addBlobberId is the id of the blobber to add to the allocation.
  • removeBlobberId is the id of the blobber to remove from the allocation.

returns the minimum lock demand for the update operation and an error if any.

func GetVersion

func GetVersion() string

GetVersion - returns version string

func InitBlockDownloader

func InitBlockDownloader(blobbers []*blockchain.StorageNode, workerCount int)

func InitCommitWorker

func InitCommitWorker(blobbers []*blockchain.StorageNode)

func InsertKilledProviderID added in v1.17.13

func InsertKilledProviderID(snId *StorageNodeIdField) (string, int64, error)

func IsErrCode added in v1.8.17

func IsErrCode(err error, code string) bool

func KillProvider added in v1.8.16

func KillProvider(providerId string, providerType ProviderType) (string, int64, error)

KillProvider kills a blobber or a validator (txn: `storagesc.kill_blobber` or `storagesc.kill_validator`)

  • providerId is the id of the provider.
  • providerType` is the type of the provider, either 3 for `ProviderBlobber` or 4 for `ProviderValidator.

func NewSignalContext added in v1.3.0

func NewSignalContext(ctx context.Context) context.Context

NewSignalContext create SignalContext instance

func ResetAllocationStats added in v1.14.0

func ResetAllocationStats(allocationId string) (string, int64, error)

func ResetBlobberStats added in v1.13.0

func ResetBlobberStats(rbs *ResetBlobberStatsDto) (string, int64, error)

ResetBlobberStats resets the stats of a blobber (txn: `storagesc.reset_blobber_stats`)

  • rbs is the reset blobber stats dto, contains the blobber id and its stats.

func ResetBlobberVersion added in v1.17.13

func ResetBlobberVersion(snId *StorageNodeIdField) (string, int64, error)

func SetDownloadWorkerCount added in v1.15.3

func SetDownloadWorkerCount(count int)

func SetHighModeWorkers added in v1.15.3

func SetHighModeWorkers(workers int)

func SetLogFile

func SetLogFile(logFile string, verbose bool)

SetLogFile set the log file and verbosity levels

  • logFile: Log file
  • verbose: true - console output; false - no console output

func SetLogLevel

func SetLogLevel(lvl int)

SetLogLevel set the log level.

  • lvl: 0 disabled; higher number (upto 4) more verbosity

func SetMultiOpBatchSize added in v1.11.4

func SetMultiOpBatchSize(size int)

func SetNumBlockDownloads

func SetNumBlockDownloads(num int)

SetNumBlockDownloads - set the number of block downloads, needs to be between 1 and 500 (inclusive). Default is 20.

  • num: the number of block downloads

func SetSaveProgress added in v1.14.6

func SetSaveProgress(save bool)

func SetShouldVerifyHash added in v1.14.0

func SetShouldVerifyHash(verify bool)

func SetSingleClietnMode added in v1.14.0

func SetSingleClietnMode(mode bool)

func SetUploadMode added in v1.14.0

func SetUploadMode(mode UploadMode)

func SetWasm added in v1.8.17

func SetWasm()

func ShutdownProvider added in v1.8.16

func ShutdownProvider(providerType ProviderType, providerID string) (string, int64, error)

ShutdownProvider shuts down a blobber or a validator (txn: `storagesc.shutdown_blobber` or `storagesc.shutdown_validator`)

  • providerId is the id of the provider.
  • providerType` is the type of the provider, either 3 for `ProviderBlobber` or 4 for `ProviderValidator.

func StakePoolLock

func StakePoolLock(providerType ProviderType, providerID string, value, fee uint64) (hash string, nonce int64, err error)

StakePoolLock locks tokens in a stake pool. This function is the entry point for the staking operation. Provided the provider type and provider ID, the value is locked in the stake pool between the SDK client and the provider. Based on the locked amount, the client will get rewards as share of the provider's rewards.

  • providerType: provider type
  • providerID: provider ID
  • value: value to lock
  • fee: transaction fee

func StakePoolUnlock

func StakePoolUnlock(providerType ProviderType, providerID string, fee uint64) (unstake int64, nonce int64, err error)

StakePoolUnlock unlocks a stake pool tokens. If tokens can't be unlocked due to opened offers, then it returns time where the tokens can be unlocked, marking the pool as 'want to unlock' to avoid its usage in offers in the future. The time is maximal time that can be lesser in some cases. To unlock tokens can't be unlocked now, wait the time and unlock them (call this function again).

  • providerType: provider type
  • providerID: provider ID
  • fee: transaction fee

func StartWriteWorker added in v1.8.17

func StartWriteWorker(ctx context.Context, source io.Reader, dataChan chan *DataChan, chunkDataSizePerRead int64)

func StorageSmartContractTxn added in v1.12.1

func StorageSmartContractTxn(sn transaction.SmartContractTxnData) (
	hash, out string, nonce int64, txn *transaction.Transaction, err error)

func TransferAllocation added in v1.8.14

func TransferAllocation(allocationId, newOwner, newOwnerPublicKey string) (string, int64, error)

TransferAllocation transfers the ownership of an allocation to a new owner. (txn: `storagesc.update_allocation_request`)

  • allocationId is the id of the allocation.
  • newOwner is the client id of the new owner.
  • newOwnerPublicKey is the public key of the new owner.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func UpdateAllocation

func UpdateAllocation(
	size int64,
	extend bool,
	allocationID string,
	lock uint64,
	addBlobberId, addBlobberAuthTicket, removeBlobberId, ownerSigninPublicKey string,
	setThirdPartyExtendable bool, fileOptionsParams *FileOptionsParameters,
) (hash string, nonce int64, err error)

UpdateAllocation sends an update request for an allocation (txn: `storagesc.update_allocation_request`)

  • size is the size of the allocation.
  • extend is a flag indicating whether to extend the allocation.
  • allocationID is the id of the allocation.
  • lock is the lock value for the transaction (how much tokens to lock to the allocation, in SAS).
  • addBlobberId is the id of the blobber to add to the allocation.
  • addBlobberAuthTicket is the auth ticket of the blobber to add to the allocation, in case the blobber is restricted.
  • removeBlobberId is the id of the blobber to remove from the allocation.
  • setThirdPartyExtendable is a flag indicating whether the allocation can be extended by a third party.
  • fileOptionsParams is the file options parameters for the allocation, which control the usage permissions of the files in the allocation.

returns the hash of the transaction, the nonce of the transaction and an error if any.

func UpdateBlobberSettings

func UpdateBlobberSettings(blob *UpdateBlobber) (resp string, nonce int64, err error)

UpdateBlobberSettings updates the settings of a blobber (txn: `storagesc.update_blobber_settings`)

  • blob is the update blobber request inputs.

func UpdateValidatorSettings added in v1.8.5

func UpdateValidatorSettings(v *UpdateValidator) (resp string, nonce int64, err error)

UpdateValidatorSettings updates the settings of a validator (txn: `storagesc.update_validator_settings`)

  • v is the update validator request inputs.

func ValidateRemoteFileName added in v1.8.10

func ValidateRemoteFileName(remotePath string) error

func WritePoolLock

func WritePoolLock(allocID string, tokens, fee uint64) (hash string, nonce int64, err error)

WritePoolLock locks given number of tokes for given duration in read pool.

  • allocID: allocation ID
  • tokens: number of tokens to lock
  • fee: transaction fee

func WritePoolUnlock

func WritePoolUnlock(allocID string, fee uint64) (hash string, nonce int64, err error)

WritePoolUnlock unlocks ALL tokens of a write pool. Needs to be cancelled first.

  • allocID: allocation ID
  • fee: transaction fee

Types

type AllocStatus added in v1.8.17

type AllocStatus byte
const (
	Commit AllocStatus = iota
	Repair
	Broken
	Rollback
)

type Allocation

type Allocation struct {
	// ID is the unique identifier of the allocation.
	ID string `json:"id"`
	// Tx is the transaction hash of the latest transaction related to the allocation.
	Tx string `json:"tx"`

	// DataShards is the number of data shards.
	DataShards int `json:"data_shards"`

	// ParityShards is the number of parity shards.
	ParityShards int `json:"parity_shards"`

	// Size is the size of the allocation.
	Size int64 `json:"size"`

	// Expiration is the expiration date of the allocation.
	Expiration int64 `json:"expiration_date"`

	// Owner is the id of the owner of the allocation.
	Owner string `json:"owner_id"`

	// OwnerPublicKey is the public key of the owner of the allocation.
	OwnerPublicKey string `json:"owner_public_key"`

	// Payer is the id of the payer of the allocation.
	Payer string `json:"payer_id"`

	// Blobbers is the list of blobbers that store the data of the allocation.
	Blobbers []*blockchain.StorageNode `json:"blobbers"`

	// Stats contains the statistics of the allocation.
	Stats *AllocationStats `json:"stats"`

	// TimeUnit is the time unit of the allocation.
	TimeUnit time.Duration `json:"time_unit"`

	// WritePool is the write pool of the allocation.
	WritePool common.Balance `json:"write_pool"`

	// BlobberDetails contains real terms used for the allocation.
	// If the allocation has updated, then terms calculated using
	// weighted average values.
	BlobberDetails []*BlobberAllocation `json:"blobber_details"`

	// ReadPriceRange is requested reading prices range.
	ReadPriceRange PriceRange `json:"read_price_range"`

	// WritePriceRange is requested writing prices range.
	WritePriceRange PriceRange `json:"write_price_range"`

	// MinLockDemand is the minimum lock demand of the allocation.
	MinLockDemand float64 `json:"min_lock_demand"`

	// ChallengeCompletionTime is the time taken to complete a challenge.
	ChallengeCompletionTime time.Duration `json:"challenge_completion_time"`

	// StartTime is the start time of the allocation.
	StartTime common.Timestamp `json:"start_time"`

	// Finalized is the flag to indicate if the allocation is finalized.
	Finalized bool `json:"finalized,omitempty"`

	// Cancelled is the flag to indicate if the allocation is cancelled.
	Canceled bool `json:"canceled,omitempty"`

	// MovedToChallenge is the amount moved to challenge pool related to the allocation.
	MovedToChallenge common.Balance `json:"moved_to_challenge,omitempty"`

	// MovedBack is the amount moved back from the challenge pool related to the allocation.
	MovedBack common.Balance `json:"moved_back,omitempty"`

	// MovedToValidators is the amount moved to validators related to the allocation.
	MovedToValidators common.Balance `json:"moved_to_validators,omitempty"`

	// FileOptions is a bitmask of file options, which are the permissions of the allocation.
	FileOptions uint16 `json:"file_options"`

	IsEnterprise bool `json:"is_enterprise"`

	StorageVersion int `json:"storage_version"`

	// Owner ecdsa public key
	OwnerSigningPublicKey string `json:"owner_signing_public_key"`

	// FileOptions to define file restrictions on an allocation for third-parties
	// default 00000000 for all crud operations suggesting only owner has the below listed abilities.
	// enabling option/s allows any third party to perform certain ops
	// 		00000001 - 1  - upload
	// 		00000010 - 2  - delete
	// 		00000100 - 4  - update
	// 		00001000 - 8  - move
	// 		00010000 - 16 - copy
	// 		00100000 - 32 - rename
	ThirdPartyExtendable bool `json:"third_party_extendable"`
	// contains filtered or unexported fields
}

Allocation represents a storage allocation.

func GetAllocation

func GetAllocation(allocationID string) (*Allocation, error)

GetAllocation - get allocation from given allocation id

  • allocationID: the allocation id

returns the allocation instance and error if any

func GetAllocationForUpdate added in v1.17.13

func GetAllocationForUpdate(allocationID string) (*Allocation, error)

GetAllocationForUpdate - get allocation for update from given allocation id without calling init allocation

func GetAllocationFromAuthTicket

func GetAllocationFromAuthTicket(authTicket string) (*Allocation, error)

GetAllocationFromAuthTicket - get allocation from given auth ticket hash. AuthTicket is used to access free allocations, and it's generated by the Free Storage Assigner.

  • authTicket: the auth ticket hash

returns the allocation instance and error if any

func GetAllocations

func GetAllocations() ([]*Allocation, error)

GetAllocations - get all allocations for the current client

returns the list of allocations and error if any

func GetAllocationsForClient

func GetAllocationsForClient(clientID string) ([]*Allocation, error)

GetAllocationsForClient - get all allocations for given client id

  • clientID: the client id

returns the list of allocations and error if any

func (*Allocation) CanCopy added in v1.8.13

func (a *Allocation) CanCopy() bool

CanCopy returns true if the allocation grants copy operation

func (*Allocation) CanDelete added in v1.8.13

func (a *Allocation) CanDelete() bool

CanDelete returns true if the allocation grants delete operation

func (*Allocation) CanMove added in v1.8.13

func (a *Allocation) CanMove() bool

CanMove returns true if the allocation grants move operation

func (*Allocation) CanRename added in v1.8.13

func (a *Allocation) CanRename() bool

CanRename returns true if the allocation grants rename operation

func (*Allocation) CanUpdate added in v1.8.13

func (a *Allocation) CanUpdate() bool

CanUpdate returns true if the allocation grants update operation

func (*Allocation) CanUpload added in v1.8.13

func (a *Allocation) CanUpload() bool

CanUpload returns true if the allocation grants upload operation

func (*Allocation) CancelDownload

func (a *Allocation) CancelDownload(remotepath string) error

CancelDownload cancels the download operation for the specified remote path. It cancels the download operation and removes the download request from the download progress map.

  • remotepath: The remote path of the file to cancel the download operation.

func (*Allocation) CancelRepair

func (a *Allocation) CancelRepair() error

CancelRepair cancels the repair operation for the allocation. It cancels the repair operation and returns an error if no repair is in progress for the allocation.

func (*Allocation) CancelUpload

func (a *Allocation) CancelUpload(remotePath string) error

CancelUpload cancels the upload operation for the specified remote path. It cancels the upload operation and returns an error if the remote path is not found.

  • remotePath: The remote path to cancel the upload operation.

func (*Allocation) CheckAllocStatus added in v1.8.17

func (a *Allocation) CheckAllocStatus() (AllocStatus, []BlobberStatus, error)

CheckAllocStatus checks the status of the allocation and returns the status of the allocation and its blobbers.

func (*Allocation) DeleteFile

func (a *Allocation) DeleteFile(path string) error

DeleteFile deletes a file from the allocation. The file is deleted from the allocation and the blobbers.

  • path: the path of the file to delete.

func (*Allocation) DoMultiOperation added in v1.8.17

func (a *Allocation) DoMultiOperation(operations []OperationRequest, opts ...MultiOperationOption) error

DoMultiOperation performs multiple operations on the allocation. The operations are performed in parallel.

  • operations: the operations to perform.
  • opts: the options of the multi operation as operation functions that customize the multi operation.

func (*Allocation) DownloadByBlocksToFileHandler added in v1.8.17

func (a *Allocation) DownloadByBlocksToFileHandler(
	fileHandler sys.File,
	remotePath string,
	startBlock, endBlock int64,
	numBlocks int,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
	downloadReqOpts ...DownloadRequestOption,
) error

DownloadFileByBlockToFileHandler adds a download operation of a file by block to a file handler. Triggers the download operations if the added download operation is final. The file is downloaded from the allocation to the file handler in blocks.

  • fileHandler: the file handler to download the file to.
  • remotePath: the remote path of the file to download.
  • startBlock: the start block of the file to download.
  • endBlock: the end block of the file to download.
  • numBlocks: the number of blocks to download.
  • verifyDownload: a flag to verify the download. If true, the download should be verified against the client keys.
  • status: the status callback function. Will be used to gather the status of the download operation.
  • isFinal: a flag to indicate if the download is the final download, meaning no more downloads are expected. It triggers the finalization of the download operation.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadByBlocksToFileHandlerFromAuthTicket added in v1.8.17

func (a *Allocation) DownloadByBlocksToFileHandlerFromAuthTicket(
	fileHandler sys.File,
	authTicket string,
	remoteLookupHash string,
	startBlock, endBlock int64,
	numBlocks int,
	remoteFilename string,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
	downloadReqOpts ...DownloadRequestOption,
) error

DownloadByBlocksToFileHandlerFromAuthTicket adds a download operation of a file from the allocation to the specified file handler using the provided authentication ticket. Triggers the downaload operations if this download request is the final one.

Parameters:

  • fileHandler: The file handler to write the downloaded file to.
  • authTicket: The authentication ticket for accessing the allocation.
  • remoteLookupHash: The lookup hash of the remote file.
  • startBlock: The starting block number to download.
  • endBlock: The ending block number to download.
  • numBlocks: The number of blocks to download.
  • remoteFilename: The name of the remote file.
  • verifyDownload: A boolean indicating whether to verify the downloaded file.
  • status: A callback function to receive status updates during the download.
  • isFinal: A boolean indicating whether this is the final download request.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadDirectory added in v1.17.0

func (a *Allocation) DownloadDirectory(ctx context.Context, remotePath, localPath, authTicket string, sb StatusCallback) error

func (*Allocation) DownloadFile

func (a *Allocation) DownloadFile(localPath string, remotePath string, verifyDownload bool, status StatusCallback, isFinal bool, downloadReqOpts ...DownloadRequestOption) error

func (*Allocation) DownloadFileByBlock

func (a *Allocation) DownloadFileByBlock(
	localPath string, remotePath string, startBlock int64, endBlock int64,
	numBlocks int, verifyDownload bool, status StatusCallback, isFinal bool, downloadReqOpts ...DownloadRequestOption) error

TODO: Use a map to store the download request and use flag isFinal to start the download, calculate readCount in parallel if possible

func (*Allocation) DownloadFileToFileHandler added in v1.8.17

func (a *Allocation) DownloadFileToFileHandler(
	fileHandler sys.File,
	remotePath string,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
	downloadReqOpts ...DownloadRequestOption,
) error

DownloadFileToFileHandler adds a download operation a file to a file handler. Triggers the download operations if the added download operation is final. The file is downloaded from the allocation to the file handler.

  • fileHandler: the file handler to download the file to.
  • remotePath: the remote path of the file to download.
  • verifyDownload: a flag to verify the download. If true, the download should be verified against the client keys.
  • status: the status callback function. Will be used to gather the status of the download operation.
  • isFinal: a flag to indicate if the download is the final download, meaning no more downloads are expected. It triggers the finalization of the download operation.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadFileToFileHandlerFromAuthTicket added in v1.8.17

func (a *Allocation) DownloadFileToFileHandlerFromAuthTicket(
	fileHandler sys.File,
	authTicket string,
	remoteLookupHash string,
	remoteFilename string,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
	downloadReqOpts ...DownloadRequestOption,
) error

DownloadFileToFileHandlerFromAuthTicket adds a download operation of a file from the allocation to the specified file handler using the provided authentication ticket. Triggers the downaload operations if this download request is the final one.

Parameters:

  • fileHandler: The file handler to write the downloaded file to.
  • authTicket: The authentication ticket for accessing the allocation.
  • remoteLookupHash: The lookup hash of the remote file.
  • remoteFilename: The name of the remote file.
  • verifyDownload: A boolean indicating whether to verify the downloaded file.
  • status: A callback function to receive status updates during the download.
  • isFinal: A boolean indicating whether this is the final download request.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

Returns: - An error if the download fails, nil otherwise.

func (*Allocation) DownloadFromAuthTicket

func (a *Allocation) DownloadFromAuthTicket(localPath string, authTicket string,
	remoteLookupHash string, remoteFilename string, verifyDownload bool, status StatusCallback, isFinal bool, downloadReqOpts ...DownloadRequestOption) error

DownloadFromAuthTicket downloads a file from the allocation to the specified local path using the provided authentication ticket. Triggers the downaload operations if this download request is the final one.

Parameters:

  • localPath: The local path to save the downloaded file.
  • authTicket: The authentication ticket for accessing the allocation.
  • remoteLookupHash: The lookup hash of the remote file.
  • remoteFilename: The name of the remote file.
  • verifyDownload: A boolean indicating whether to verify the downloaded file.
  • status: A callback function to receive status updates during the download.
  • isFinal: A boolean indicating whether this is the final download request.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadFromAuthTicketByBlocks

func (a *Allocation) DownloadFromAuthTicketByBlocks(localPath string,
	authTicket string, startBlock int64, endBlock int64, numBlocks int,
	remoteLookupHash string, remoteFilename string, verifyDownload bool,
	status StatusCallback, isFinal bool, downloadReqOpts ...DownloadRequestOption) error

DownloadFromAuthTicketByBlocks downloads a file from the allocation to the specified local path using the provided authentication ticket. The file is downloaded by blocks from the specified start block to the end block. Triggers the downaload operations if this download request is the final one.

Parameters:

  • localPath: The local path to save the downloaded file.
  • authTicket: The authentication ticket for accessing the allocation.
  • startBlock: The starting block number to download.
  • endBlock: The ending block number to download.
  • numBlocks: The number of blocks to download.
  • remoteLookupHash: The lookup hash of the remote file.
  • remoteFilename: The name of the remote file.
  • verifyDownload: A boolean indicating whether to verify the downloaded file.
  • status: A callback function to receive status updates during the download.
  • isFinal: A boolean indicating whether this is the final download request.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadFromBlobber added in v1.8.17

func (a *Allocation) DownloadFromBlobber(blobberID, localPath, remotePath string, status StatusCallback, opts ...DownloadRequestOption) error

DownloadFromBlobber downloads a file from a specific blobber.

  • blobberID: the ID of the blobber to download the file from.
  • localPath: the local path to download the file to.
  • remotePath: the remote path of the file to download.
  • status: the status callback function. Will be used to gather the status of the download operation.
  • opts: the options of the download request as operation functions that customize the download request.

func (*Allocation) DownloadFromReader added in v1.8.16

func (a *Allocation) DownloadFromReader(
	remotePath, localPath, lookupHash, authTicket, contentMode string,
	verifyDownload bool,
	blocksPerMarker uint,
) error

DownloadFromReader downloads a file from the allocation to the specified local path using the provided reader. [DEPRECATED] Use DownloadFile or DownloadFromAuthTicket instead.

func (*Allocation) DownloadThumbnail

func (a *Allocation) DownloadThumbnail(localPath string, remotePath string, verifyDownload bool, status StatusCallback, isFinal bool) error

DownloadThumbnail adds a download operation of a thumbnail from the allocation. Triggers the download operations if the added download operation is final. The thumbnail is downloaded from the allocation to the local path.

  • localPath: the local path to download the thumbnail to.
  • remotePath: the remote path of the thumbnail to download.
  • verifyDownload: a flag to verify the download. If true, the download should be verified against the client keys.
  • status: the status callback function. Will be used to gather the status of the download operation.
  • isFinal: a flag to indicate if the download is the final download, meaning no more downloads are expected. It triggers the finalization of the download operation.

func (*Allocation) DownloadThumbnailFromAuthTicket

func (a *Allocation) DownloadThumbnailFromAuthTicket(
	localPath string,
	authTicket string,
	remoteLookupHash string,
	remoteFilename string,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
	downloadReqOpts ...DownloadRequestOption,
) error

DownloadThumbnailFromAuthTicket downloads a thumbnail from the allocation to the specified local path using the provided authentication ticket. Triggers the downaload operations if this download request is the final one.

Parameters:

  • localPath: The local path to save the downloaded thumbnail.
  • authTicket: The authentication ticket for accessing the allocation.
  • remoteLookupHash: The lookup hash of the remote file.
  • remoteFilename: The name of the remote file.
  • verifyDownload: A boolean indicating whether to verify the downloaded thumbnail.
  • status: A callback function to receive status updates during the download.
  • isFinal: A boolean indicating whether this is the final download request.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadThumbnailToFileHandler added in v1.8.17

func (a *Allocation) DownloadThumbnailToFileHandler(
	fileHandler sys.File,
	remotePath string,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
	downloadReqOpts ...DownloadRequestOption,
) error

DownloadThumbnailToFileHandler adds a download operation of a thumbnail to a file handler. Triggers the download operations if the added download operation is final. The thumbnail is downloaded from the allocation to the file handler.

  • fileHandler: the file handler to download the thumbnail to.
  • remotePath: the remote path of the thumbnail to download.
  • verifyDownload: a flag to verify the download. If true, the download should be verified against the client keys.
  • status: the status callback function. Will be used to gather the status of the download operation.
  • isFinal: a flag to indicate if the download is the final download, meaning no more downloads are expected. It triggers the finalization of the download operation.
  • downloadReqOpts: the options of the download operation as operation functions that customize the download operation.

func (*Allocation) DownloadThumbnailToFileHandlerFromAuthTicket added in v1.8.17

func (a *Allocation) DownloadThumbnailToFileHandlerFromAuthTicket(
	fileHandler sys.File,
	authTicket string,
	remoteLookupHash string,
	remoteFilename string,
	verifyDownload bool,
	status StatusCallback,
	isFinal bool,
) error

DownloadThumbnailToFileHandlerFromAuthTicket adds a download operation of a thumbnail from the allocation to the specified file handler using the provided authentication ticket. Triggers the downaload operations if this download request is the final one.

Parameters:

  • fileHandler: The file handler to write the downloaded thumbnail to.
  • authTicket: The authentication ticket for accessing the allocation.
  • remoteLookupHash: The lookup hash of the remote file.
  • remoteFilename: The name of the remote file.
  • verifyDownload: A boolean indicating whether to verify the downloaded thumbnail.
  • status: A callback function to receive status updates during the download.
  • isFinal: A boolean indicating whether this is the final download request.

func (*Allocation) EncryptAndUpdateFile

func (a *Allocation) EncryptAndUpdateFile(workdir string, localpath string, remotepath string,
	status StatusCallback) error

EncryptAndUpdateFile [Deprecated]please use CreateChunkedUpload

func (*Allocation) EncryptAndUpdateFileWithThumbnail

func (a *Allocation) EncryptAndUpdateFileWithThumbnail(workdir string, localpath string,
	remotepath string, thumbnailpath string, status StatusCallback) error

EncryptAndUpdateFileWithThumbnail [Deprecated]please use CreateChunkedUpload

func (*Allocation) EncryptAndUploadFile

func (a *Allocation) EncryptAndUploadFile(workdir string, localpath string, remotepath string,
	status StatusCallback) error

EncryptAndUploadFile [Deprecated]please use CreateChunkedUpload

func (*Allocation) EncryptAndUploadFileWithThumbnail

func (a *Allocation) EncryptAndUploadFileWithThumbnail(
	workdir string,
	localpath string,
	remotepath string,
	thumbnailpath string,

	status StatusCallback,
) error

EncryptAndUploadFileWithThumbnail [Deprecated]please use CreateChunkedUpload

func (*Allocation) GetAllocationDiff

func (a *Allocation) GetAllocationDiff(lastSyncCachePath string, localRootPath string, localFileFilters []string, remoteExcludePath []string, remotePath string) ([]FileDiff, error)

GetAllocationDiff retrieves the difference between the remote and local filesystem representation of the allocation

  • lastSyncCachePath is the path to the last sync cache file, which carries exact state of the remote filesystem
  • localRootPath is the local root path of the allocation
  • localFileFilters is the list of local file filters
  • remoteExcludePath is the list of remote exclude paths
  • remotePath is the remote path of the allocation

func (*Allocation) GetAllocationFileReader added in v1.8.16

func (a *Allocation) GetAllocationFileReader(
	remotePath, lookupHash, authTicket, contentMode string,
	verifyDownload bool,
	blocksPerMarker uint,
) (io.ReadSeekCloser, error)

GetAllocationFileReader will check file ref existence and returns an instance that provides io.ReadSeekerCloser interface. [DEPRECATED] Use DownloadFile or DownloadFromAuthTicket instead.

func (*Allocation) GetAuthTicket

func (a *Allocation) GetAuthTicket(path, filename string,
	referenceType, refereeClientID, refereeEncryptionPublicKey string, expiration int64, availableAfter *time.Time) (string, error)

GetAuthTicket generates an authentication ticket for the specified file or directory in the allocation. The authentication ticket is used to grant access to the file or directory to another client. The function takes the following parameters:

  • path: The path of the file or directory (should be absolute).
  • filename: The name of the file.
  • referenceType: The type of reference (file or directory).
  • refereeClientID: The client ID of the referee.
  • refereeEncryptionPublicKey: The encryption public key of the referee.
  • expiration: The expiration time of the authentication ticket in Unix timestamp format.
  • availableAfter: The time after which the authentication ticket becomes available in Unix timestamp format.

Returns the authentication ticket as a base64-encoded string and an error if any.

func (*Allocation) GetAuthTicketForShare

func (a *Allocation) GetAuthTicketForShare(
	path, filename, referenceType, refereeClientID string) (string, error)

GetAuthTicketForShare returns the authentication ticket for sharing a file or directory within the allocation. It generates an authentication ticket using the provided parameters and the current time. The authentication ticket can be used by the recipient to access the shared file or directory.

Parameters:

  • path: The path of the file or directory to be shared.
  • filename: The name of the file to be shared.
  • referenceType: The type of reference for the shared file or directory.
  • refereeClientID: The client ID of the recipient who will be granted access to the shared file or directory.

Returns:

  • string: The authentication ticket for sharing the file or directory.
  • error: An error if the authentication ticket generation fails.

func (*Allocation) GetBlobberStats

func (a *Allocation) GetBlobberStats() map[string]*BlobberAllocationStats

GetBlobberStats returns the statistics of the blobbers in the allocation.

func (*Allocation) GetChunkReadSize added in v1.8.17

func (a *Allocation) GetChunkReadSize(encrypt bool) int64

GetChunkReadSize returns the size of the chunk to read. The size of the chunk to read is calculated based on the data shards and the encryption flag. If the encryption flag is true, the size of the chunk to read is the chunk size minus the encrypted data padding size and the encryption header size. Otherwise, the size of the chunk to read is the chunk size multiplied by the data shards.

  • encrypt: the flag to indicate if the chunk is encrypted.

func (*Allocation) GetCurrentVersion added in v1.8.17

func (a *Allocation) GetCurrentVersion() (bool, error)

GetCurrentVersion retrieves the current version of the allocation. The version of the allocation is the version of the latest write marker. The versions are gathered from the blobbers of the allocation. If the versions are not consistent, the allocation is repaired. Returns a boolean indicating if the allocation is repaired, and an error if any. In case of more than 2 versions found, an error is returned.

func (*Allocation) GetFileMeta

func (a *Allocation) GetFileMeta(path string) (*ConsolidatedFileMeta, error)

GetFileMeta retrieves the file meta data of a file in the allocation. The file meta data includes the file type, name, hash, lookup hash, mime type, path, size, number of blocks, encrypted key, collaborators, actual file size, actual thumbnail hash, and actual thumbnail size.

  • path: the path of the file to get the meta data.

func (*Allocation) GetFileMetaByName added in v1.17.0

func (a *Allocation) GetFileMetaByName(fileName string) ([]*ConsolidatedFileMetaByName, error)

GetFileMetaByName retrieve consolidated file metadata given its name (its full path starting from root "/").

  • fileName: full file path starting from the allocation root.

func (*Allocation) GetFileMetaFromAuthTicket

func (a *Allocation) GetFileMetaFromAuthTicket(authTicket string, lookupHash string) (*ConsolidatedFileMeta, error)

GetFileMetaFromAuthTicket retrieves the file meta data of a file in the allocation using the auth ticket. The file meta data includes the file type, name, hash, lookup hash, mime type, path, size, number of blocks, actual file size, actual thumbnail hash, and actual thumbnail size. The auth ticket is used to access the file meta data of a shared file. Usually used for file sharing, the owner sets the file as shared and generates an auth ticket which they should share with other non-owner users.

  • authTicket: the auth ticket to get the file meta data.
  • lookupHash: the lookup hash of the file to get the meta data. It's an augmentation of the allocation ID and the path hash.

func (*Allocation) GetFileStats

func (a *Allocation) GetFileStats(path string) (map[string]*FileStats, error)

GetFileStats retrieves the file stats of a file in the allocation. The file stats include the number of blocks, size, and actual file size.

  • path: the path of the file to get the stats.

func (*Allocation) GetMaxStorageCost

func (a *Allocation) GetMaxStorageCost(size int64) (float64, error)

GetMaxStorageCost returns the maximum storage cost from the blobbers in the allocation.

  • size: The size of the file to calculate the storage cost.

func (*Allocation) GetMaxStorageCostFromBlobbers added in v1.2.82

func (a *Allocation) GetMaxStorageCostFromBlobbers(size int64, blobbers []*BlobberAllocation) (float64, error)

GetMaxStorageCostFromBlobbers returns the maximum storage cost from a given list of allocation blobbers.

  • size: The size of the file to calculate the storage cost.
  • blobbers: The list of blobbers to calculate the storage cost.

func (*Allocation) GetMaxWriteRead

func (a *Allocation) GetMaxWriteRead() (maxW float64, maxR float64, err error)

GetMaxWriteRead returns the maximum write and read prices from the blobbers in the allocation.

func (*Allocation) GetMaxWriteReadFromBlobbers added in v1.2.82

func (a *Allocation) GetMaxWriteReadFromBlobbers(blobbers []*BlobberAllocation) (maxW float64, maxR float64, err error)

func (*Allocation) GetMinStorageCost

func (a *Allocation) GetMinStorageCost(size int64) (common.Balance, error)

GetMinStorageCost returns the minimum storage cost from the blobbers in the allocation.

  • size: The size of the file to calculate the storage cost.

func (*Allocation) GetMinWriteRead

func (a *Allocation) GetMinWriteRead() (minW float64, minR float64, err error)

GetMinWriteRead returns the minimum write and read prices from the blobbers in the allocation.

func (*Allocation) GetRecentlyAddedRefs added in v1.8.7

func (a *Allocation) GetRecentlyAddedRefs(page int, fromDate int64, pageLimit int) (*RecentlyAddedRefResult, error)

GetRecentlyAddedRefs retrieves the recently added refs in the allocation. The refs are the representations of files and directories in the blobber database. This function will retrieve paginated objectTree and will handle concensus; Required tree should be made in application side.

  • page: the page number of the refs to get.
  • fromDate: the date to get the refs from.
  • pageLimit: the limit of the refs to get per page.

func (*Allocation) GetRefs added in v1.3.0

func (a *Allocation) GetRefs(path, offsetPath, updatedDate, offsetDate, fileType, refType string, level, pageLimit int, opts ...ObjectTreeRequestOption) (*ObjectTreeResult, error)

GetRefs retrieve file refs that are children of a remote path. Used by the owner to get the refs of the files and directories in the allocation. This function will retrieve paginated objectTree and will handle concensus; Required tree should be made in application side.

  • path: the path to get the refs.
  • offsetPath: the offset path to get the refs.
  • updatedDate: the updated date to get the refs.
  • offsetDate: the offset date to get the refs.
  • fileType: the file type to get the refs.
  • refType: the ref type to get the refs, e.g., file or directory.
  • level: the level of the refs to get relative to the path root (strating from 0 as the root path).
  • pageLimit: the limit of the refs to get per page.

func (*Allocation) GetRefsFromLookupHash added in v1.8.16

func (a *Allocation) GetRefsFromLookupHash(pathHash, offsetPath, updatedDate, offsetDate, fileType, refType string, level, pageLimit int) (*ObjectTreeResult, error)

func (*Allocation) GetRefsWithAuthTicket added in v1.8.16

func (a *Allocation) GetRefsWithAuthTicket(authToken, offsetPath, updatedDate, offsetDate, fileType, refType string, level, pageLimit int) (*ObjectTreeResult, error)

GetRefsWithAuthTicket retrieve file refs that are children of a shared remote path. Refs are the representations of files and directories in the blobber database. An auth ticket is provided in case the path is shared, and usually by a non-owner user. This function will retrieve paginated objectTree and will handle concensus; Required tree should be made in application side.

  • authToken: the auth ticket to get the refs.
  • offsetPath: the offset path to get the refs.
  • updatedDate: the updated date to get the refs.
  • offsetDate: the offset date to get the refs.
  • fileType: the file type to get the refs.
  • refType: the ref type to get the refs, e.g., file or directory.
  • level: the level of the refs to get relative to the path root (strating from 0 as the root path).
  • pageLimit: the limit of the refs to get per page.

func (*Allocation) GetRemoteFileMap

func (a *Allocation) GetRemoteFileMap(exclMap map[string]int, remotepath string) (map[string]FileInfo, error)

GetRemoteFileMap retrieve the remote file map

  • exclMap is the exclude map, a map of paths to exclude
  • remotepath is the remote path to get the file map

func (*Allocation) GetStats

func (a *Allocation) GetStats() *AllocationStats

GetStats returns the statistics of the allocation.

func (*Allocation) InitAllocation

func (a *Allocation) InitAllocation()

InitAllocation initializes the allocation.

func (*Allocation) ListDir

func (a *Allocation) ListDir(path string, opts ...ListRequestOptions) (*ListResult, error)

ListDir lists the allocation directory.

  • path: the path of the directory to list.
  • opts: the options of the list request as operation functions that customize the list request.

func (*Allocation) ListDirFromAuthTicket

func (a *Allocation) ListDirFromAuthTicket(authTicket string, lookupHash string, opts ...ListRequestOptions) (*ListResult, error)

ListDirFromAuthTicket lists the allocation directory encoded in the given auth ticket. Usually used for directory sharing, the owner sets the directory as shared and generates an auth ticket which they should share with other non-owner users. The non-owner users can list the shared directory using the auth ticket.

  • authTicket: the auth ticket to list the directory.
  • lookupHash: the lookup hash of the directory to list. It's an augmentation of the allocation ID and the path hash.
  • opts: the options of the list request as operation functions that customize the list request.

func (*Allocation) ListObjects added in v1.17.0

func (a *Allocation) ListObjects(ctx context.Context, path, offsetPath, updatedDate, offsetDate, fileType, refType string, level, pageLimit int, opts ...ObjectTreeRequestOption) <-chan ORef

func (*Allocation) PauseUpload added in v1.14.0

func (a *Allocation) PauseUpload(remotePath string) error

PauseUpload pauses the upload operation for the specified remote path. It pauses the upload operation and returns an error if the remote path is not found.

  • remotePath: The remote path to pause the upload operation.

func (*Allocation) RepairAlloc added in v1.8.16

func (a *Allocation) RepairAlloc(statusCB StatusCallback) (err error)

RepairAlloc repairs all the files in allocation

func (*Allocation) RepairFile

func (a *Allocation) RepairFile(file sys.File, remotepath string, statusCallback StatusCallback, mask zboxutil.Uint128, ref *fileref.FileRef) *OperationRequest

RepairFile repair a file in the allocation.

  • file: the file to repair.
  • remotepath: the remote path of the file.
  • statusCallback: a callback function to get the status of the repair.
  • mask: the mask of the repair descriping the blobbers to repair.
  • ref: the file reference, a representation of the file in the database.

func (*Allocation) RepairRequired

func (a *Allocation) RepairRequired(remotepath string) (zboxutil.Uint128, zboxutil.Uint128, bool, *fileref.FileRef, error)

RepairRequired checks if a repair is required for the given remotepath in the allocation. The repair is required if the file is not found in all the blobbers. Returns the found mask, delete mask, a boolean indicating if the repair is required, and an error if any. The found mask is a 128-bitmask of the blobbers where the file is found. The delete mask is a 128-bitmask of the blobbers where the file is not found.

  • remotepath: the remote path of the file to check.

func (*Allocation) RepairSize added in v1.16.0

func (a *Allocation) RepairSize(remotePath string) (RepairSize, error)

RepairSize Gets the size in bytes to repair allocation

  • remotePath: the path to repair in the allocation.

func (*Allocation) RevokeShare

func (a *Allocation) RevokeShare(path string, refereeClientID string) error

RevokeShare revokes the shared access to a file or directory within the allocation. It revokes the shared access to the file or directory for the specified recipient.

Parameters:

  • path: The path of the file or directory to revoke the shared access.
  • refereeClientID: The client ID of the recipient whose shared access is to be revoked.

Returns:

  • error: An error if the shared access revocation fails.

func (*Allocation) RollbackWithMask added in v1.8.17

func (a *Allocation) RollbackWithMask(mask zboxutil.Uint128)

RollbackWithMask rolls back the latest operation from the allocation blobbers which ran it. The mask is used to specify which blobbers to rollback.

  • mask: 128-bitmask to specify which blobbers to rollback

func (*Allocation) SaveRemoteSnapshot

func (a *Allocation) SaveRemoteSnapshot(pathToSave string, remoteExcludePath []string) error

SaveRemoteSnapshot saves the remote current information to the given file. This file can be passed to GetAllocationDiff to exactly find the previous sync state to current.

  • pathToSave is the path to save the remote snapshot
  • remoteExcludePath is the list of paths to exclude

func (*Allocation) SetCheckStatus added in v1.15.0

func (a *Allocation) SetCheckStatus(checkStatus bool)

SetCheckStatus sets the check status of the allocation.

  • checkStatus: the check status to set.

func (*Allocation) SetConsensusThreshold added in v1.8.17

func (a *Allocation) SetConsensusThreshold()

func (*Allocation) StartChunkedUpload added in v1.3.0

func (a *Allocation) StartChunkedUpload(workdir, localPath string,
	remotePath string,
	status StatusCallback,
	isUpdate bool,
	isRepair bool,
	thumbnailPath string,
	encryption bool,
	webStreaming bool,
	uploadOpts ...ChunkedUploadOption,
) error

StartChunkedUpload starts a chunked upload operation. A chunked upload operation uploads a file to the allocation in chunks.

  • workdir: the working directory, where the file is stored.
  • localPath: the local path of the file to upload.
  • remotePath: the remote path of the file to upload.
  • status: the status callback function. Will be used to gather the status of the upload operation.
  • isUpdate: the update flag of the file to upload. If true, the file is to overwrite an existing file.
  • isRepair: the repair flag of the file to upload. If true, the file is to repair an existing file.
  • thumbnailPath: the path of the thumbnail of the file to upload.
  • encryption: the encryption flag of the file to upload.
  • webStreaming: the webstreaming flag of the file to upload.
  • uploadOpts: the options of the upload operation as operation functions that customize the upload operation.

func (*Allocation) StartMultiUpload added in v1.8.17

func (a *Allocation) StartMultiUpload(workdir string, localPaths []string, fileNames []string, thumbnailPaths []string, encrypts []bool, chunkNumbers []int, remotePaths []string, isUpdate []bool, isWebstreaming []bool, status StatusCallback) error

StartMultiUpload starts a multi upload operation. A multi upload operation uploads multiple files to the allocation, given ordered arrays of upload parameters. The paramteres are ordered in a way that the ith element of each array corresponds to the ith file to upload. The upload operation is done in parallel.

  • workdir: the working directory, where the files are stored.
  • localPaths: the local paths of the files to upload.
  • fileNames: the names of the files to upload.
  • thumbnailPaths: the paths of the thumbnails of the files to upload.
  • encrypts: the encryption flags of the files to upload.
  • chunkNumbers: the chunk numbers of the files to upload. Chunk number is used to upload the file in chunks.
  • remotePaths: the remote paths of the files to upload.
  • isUpdate: the update flags of the files to upload. If true, the file is to overwrite an existing file.
  • isWebstreaming: the webstreaming flags of the files to upload.
  • status: the status callback function. Will be used to gather the status of the upload operations.

Returns any error encountered during any of the upload operations, or during preparation of the upload operations.

func (*Allocation) StartRepair

func (a *Allocation) StartRepair(localRootPath, pathToRepair string, statusCB StatusCallback) error

StartRepair starts the repair operation for the specified path in the allocation. It starts the repair operation and returns an error if the path is not found. Repair operation is used to repair the files in the allocation, which are corrupted or missing in some blobbers.

  • localRootPath: The local root path to repair the files.
  • pathToRepair: The path to repair in the allocation.
  • statusCB: A callback function to receive status updates during the repair operation.

func (*Allocation) UpdateFile

func (a *Allocation) UpdateFile(workdir, localpath string, remotepath string,
	status StatusCallback) error

UpdateFile [Deprecated]please use CreateChunkedUpload

func (*Allocation) UpdateFileWithThumbnail

func (a *Allocation) UpdateFileWithThumbnail(workdir, localpath string, remotepath string,
	thumbnailpath string, status StatusCallback) error

UpdateFileWithThumbnail [Deprecated]please use CreateChunkedUpload

func (*Allocation) UpdateWithRepair added in v1.8.16

func (a *Allocation) UpdateWithRepair(
	size int64,
	extend bool,
	lock uint64,
	addBlobberId, addBlobberAuthTicket, removeBlobberId, ownerSigninPublicKey string,
	setThirdPartyExtendable bool, fileOptionsParams *FileOptionsParameters,
	statusCB StatusCallback,
) (string, error)

UpdateWithRepair updates the allocation with the specified parameters and starts the repair operation if required. It updates the allocation with the specified parameters and starts the repair operation if required.

  • size: The updated size of the allocation to update.
  • extend: A boolean indicating whether to extend the expiration of the allocation.
  • lock: The lock value to update the allocation.
  • addBlobberId: The blobber ID to add to the allocation.
  • addBlobberAuthTicket: The authentication ticket for the blobber to add to the allocation.
  • removeBlobberId: The blobber ID to remove from the allocation.
  • setThirdPartyExtendable: A boolean indicating whether to set the allocation as third-party extendable. If set to true, the allocation can be extended in terms of size by a non-owner.
  • fileOptionsParams: The file options parameters which control permissions of the files of the allocations.
  • statusCB: A callback function to receive status updates during the update operation.

func (*Allocation) UpdateWithStatus added in v1.15.4

func (a *Allocation) UpdateWithStatus(
	size int64,
	extend bool,
	lock uint64,
	addBlobberId, addBlobberAuthTicket, removeBlobberId, ownerSigninPublicKey string,
	setThirdPartyExtendable bool, fileOptionsParams *FileOptionsParameters,
	statusCB StatusCallback,
) (*Allocation, string, bool, error)

UpdateWithStatus updates the allocation with the specified parameters. It updates the allocation with the specified parameters and returns the updated allocation, hash, and a boolean indicating whether repair is required.

  • size: The updated size of the allocation to update.
  • extend: A boolean indicating whether to extend the expiration of the allocation.
  • lock: The lock value to update the allocation.
  • addBlobberId: The blobber ID to add to the allocation.
  • addBlobberAuthTicket: The authentication ticket for the blobber to add to the allocation. Used in case of adding a restricted blobber.
  • removeBlobberId: The blobber ID to remove from the allocation.
  • setThirdPartyExtendable: A boolean indicating whether to set the allocation as third-party extendable. If set to true, the allocation can be extended in terms of size by a non-owner.
  • fileOptionsParams: The file options parameters which control permissions of the files of the allocations.
  • statusCB: A callback function to receive status updates during the update operation.

Returns the updated allocation, hash, and a boolean indicating whether repair is required.

func (*Allocation) UploadAuthTicketToBlobber

func (a *Allocation) UploadAuthTicketToBlobber(authTicket string, clientEncPubKey string, availableAfter *time.Time) error

UploadAuthTicketToBlobber uploads the authentication ticket to the blobbers after creating it at the client side. The authentication ticket is uploaded to the blobbers to grant access to the file or directory to a client other than the owner.

  • authTicket: The authentication ticket to upload.
  • clientEncPubKey: The encryption public key of the client, used in case of private sharing.
  • availableAfter: The time after which the authentication ticket becomes available in Unix timestamp format.

func (*Allocation) UploadFile

func (a *Allocation) UploadFile(workdir, localpath string, remotepath string,
	status StatusCallback) error

UploadFile [Deprecated]please use CreateChunkedUpload

func (*Allocation) UploadFileWithThumbnail

func (a *Allocation) UploadFileWithThumbnail(workdir string, localpath string,
	remotepath string, thumbnailpath string,
	status StatusCallback) error

UploadFileWithThumbnail [Deprecated]please use CreateChunkedUpload

type AllocationStats

type AllocationStats struct {
	UsedSize                  int64  `json:"used_size"`
	NumWrites                 int64  `json:"num_of_writes"`
	NumReads                  int64  `json:"num_of_reads"`
	TotalChallenges           int64  `json:"total_challenges"`
	OpenChallenges            int64  `json:"num_open_challenges"`
	SuccessChallenges         int64  `json:"num_success_challenges"`
	FailedChallenges          int64  `json:"num_failed_challenges"`
	LastestClosedChallengeTxn string `json:"latest_closed_challenge"`
}

type AuthTicket

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

func InitAuthTicket

func InitAuthTicket(authTicket string) *AuthTicket

InitAuthTicket initialize auth ticket instance

  • authTicket: base64 encoded auth ticket

func (*AuthTicket) GetFileName

func (at *AuthTicket) GetFileName() (string, error)

func (*AuthTicket) GetLookupHash

func (at *AuthTicket) GetLookupHash() (string, error)

func (*AuthTicket) IsDir

func (at *AuthTicket) IsDir() (bool, error)

func (*AuthTicket) Unmarshall

func (at *AuthTicket) Unmarshall() (*marker.AuthTicket, error)

type BackPool

type BackPool struct {
	ID      string         `json:"id"`
	Balance common.Balance `json:"balance"`
}

type Blobber

type Blobber struct {
	// ID of the blobber
	ID common.Key `json:"id"`

	// BaseURL of the blobber
	BaseURL string `json:"url"`

	// Terms of the blobber
	Terms Terms `json:"terms"`

	// Capacity of the blobber
	Capacity common.Size `json:"capacity"`

	// Allocated size of the blobber
	Allocated common.Size `json:"allocated"`

	// LastHealthCheck of the blobber
	LastHealthCheck common.Timestamp `json:"last_health_check"`

	// PublicKey of the blobber
	PublicKey string `json:"-"`

	// StakePoolSettings settings of the blobber staking
	StakePoolSettings blockchain.StakePoolSettings `json:"stake_pool_settings"`

	// TotalStake of the blobber in SAS
	TotalStake int64 `json:"total_stake"`

	// UsedAllocation of the blobber in SAS
	UsedAllocation int64 `json:"used_allocation"`

	// TotalOffers of the blobber in SAS
	TotalOffers int64 `json:"total_offers"`

	// TotalServiceCharge of the blobber in SAS
	TotalServiceCharge int64 `json:"total_service_charge"`

	// UncollectedServiceCharge of the blobber in SAS
	UncollectedServiceCharge int64 `json:"uncollected_service_charge"`

	// IsKilled flag of the blobber, if true then the blobber is killed
	IsKilled bool `json:"is_killed"`

	// IsShutdown flag of the blobber, if true then the blobber is shutdown
	IsShutdown bool `json:"is_shutdown"`

	// NotAvailable flag of the blobber, if true then the blobber is not available
	NotAvailable bool `json:"not_available"`

	// IsRestricted flag of the blobber, if true then the blobber is restricted
	IsRestricted bool `json:"is_restricted"`
}

Blobber type represents blobber information.

func GetBlobber

func GetBlobber(blobberID string) (blob *Blobber, err error)

GetBlobber retrieve blobber by id.

  • blobberID: the id of blobber

func GetBlobbers

func GetBlobbers(active, stakable bool) (bs []*Blobber, err error)

GetBlobbers returns list of blobbers.

  • active: if true then only active blobbers are returned
  • stakable: if true then only stakable blobbers are returned

type BlobberAllocation

type BlobberAllocation struct {
	BlobberID       string         `json:"blobber_id"`
	Size            int64          `json:"size"`
	Terms           Terms          `json:"terms"`
	MinLockDemand   common.Balance `json:"min_lock_demand"`
	Spent           common.Balance `json:"spent"`
	Penalty         common.Balance `json:"penalty"`
	ReadReward      common.Balance `json:"read_reward"`
	Returned        common.Balance `json:"returned"`
	ChallengeReward common.Balance `json:"challenge_reward"`
	FinalReward     common.Balance `json:"final_reward"`
}

BlobberAllocation represents the blobber in the context of an allocation

type BlobberAllocationStats

type BlobberAllocationStats struct {
	BlobberID        string
	BlobberURL       string
	ID               string `json:"ID"`
	Tx               string `json:"Tx"`
	TotalSize        int64  `json:"TotalSize"`
	UsedSize         int    `json:"UsedSize"`
	OwnerID          string `json:"OwnerID"`
	OwnerPublicKey   string `json:"OwnerPublicKey"`
	Expiration       int    `json:"Expiration"`
	AllocationRoot   string `json:"AllocationRoot"`
	BlobberSize      int    `json:"BlobberSize"`
	BlobberSizeUsed  int    `json:"BlobberSizeUsed"`
	LatestRedeemedWM string `json:"LatestRedeemedWM"`
	IsRedeemRequired bool   `json:"IsRedeemRequired"`
	CleanedUp        bool   `json:"CleanedUp"`
	Finalized        bool   `json:"Finalized"`
	Terms            []struct {
		ID           int    `json:"ID"`
		BlobberID    string `json:"BlobberID"`
		AllocationID string `json:"AllocationID"`
		ReadPrice    int    `json:"ReadPrice"`
		WritePrice   int    `json:"WritePrice"`
	} `json:"Terms"`
}

BlobberAllocationStats represents the blobber allocation statistics.

type BlobberStatus added in v1.15.0

type BlobberStatus struct {
	ID     string
	Status string
}

type BlockDownloadRequest

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

type ChallengePoolInfo

type ChallengePoolInfo struct {
	ID         string           `json:"id"`
	Balance    common.Balance   `json:"balance"`
	StartTime  common.Timestamp `json:"start_time"`
	Expiration common.Timestamp `json:"expiration"`
	Finalized  bool             `json:"finalized"`
}

ChallengePoolInfo represents a challenge pool stat.

func GetChallengePoolInfo

func GetChallengePoolInfo(allocID string) (info *ChallengePoolInfo, err error)

GetChallengePoolInfo retrieve challenge pool info for given allocation.

  • allocID: allocation ID

type ChunkData added in v1.2.88

type ChunkData struct {
	// Index current index of chunks
	Index int
	// IsFinal last chunk or not
	IsFinal bool

	// ReadSize total size read from original reader (un-encoded, un-encrypted)
	ReadSize int64
	// FragmentSize fragment size for a blobber (un-encrypted)
	FragmentSize int64
	// Fragments data shared for bloobers
	Fragments [][]byte
}

ChunkData data of a chunk

type ChunkedUpload added in v1.2.88

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

ChunkedUpload upload manager with chunked upload feature

func CreateChunkedUpload added in v1.2.88

func CreateChunkedUpload(
	ctx context.Context,
	workdir string, allocationObj *Allocation,
	fileMeta FileMeta, fileReader io.Reader,
	isUpdate, isRepair bool,
	webStreaming bool, connectionId string,
	opts ...ChunkedUploadOption,
) (*ChunkedUpload, error)

func (*ChunkedUpload) Start added in v1.2.88

func (su *ChunkedUpload) Start() error

Start start/resume upload

type ChunkedUploadBlobber added in v1.3.5

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

ChunkedUploadBlobber client of blobber's upload

type ChunkedUploadChunkReader added in v1.2.88

type ChunkedUploadChunkReader interface {
	// Next read, encode and encrypt next chunk
	Next() (*ChunkData, error)

	// Read read, encode and encrypt all bytes
	Read(buf []byte) ([][]byte, error)

	//Close Hash Channel
	Close()
	//GetFileHash get file hash
	GetFileHash() (string, error)
	//Reset reset offset
	Reset()
	//Release Buffer
	Release()
}

type ChunkedUploadFormBuilder added in v1.2.88

type ChunkedUploadFormBuilder interface {
	// build form data
	Build(
		fileMeta *FileMeta, hasher Hasher, connectionID, blobberID string,
		chunkSize int64, chunkStartIndex, chunkEndIndex int,
		isFinal bool, encryptedKey, encryptedKeyPoint string, fileChunksData [][]byte,
		thumbnailChunkData []byte, shardSize int64,
	) (blobberData, error)
}

ChunkedUploadFormBuilder build form data for uploading

func CreateChunkedUploadFormBuilder added in v1.2.88

func CreateChunkedUploadFormBuilder(storageVersion int, privateSigningKey ed25519.PrivateKey) ChunkedUploadFormBuilder

CreateChunkedUploadFormBuilder create ChunkedUploadFormBuilder instance

type ChunkedUploadFormMetadata added in v1.2.88

type ChunkedUploadFormMetadata struct {
	FileBytesLen         int
	ThumbnailBytesLen    int
	ContentType          string
	FixedMerkleRoot      string
	ValidationRoot       string
	ThumbnailContentHash string
}

ChunkedUploadFormMetadata upload form metadata

type ChunkedUploadOption added in v1.2.88

type ChunkedUploadOption func(su *ChunkedUpload)

ChunkedUploadOption Generic type for chunked upload option functions

func WithActualHash added in v1.11.0

func WithActualHash(hash string) ChunkedUploadOption

WithActualHash return a wrapper option function to set actual hash of the chunked upload instance

func WithChunkNumber added in v1.7.7

func WithChunkNumber(num int) ChunkedUploadOption

WithChunkNumber set the number of chunks should be upload in a request. ignore if size <=0

  • num: number of chunks

func WithCommitTimeout added in v1.8.9

func WithCommitTimeout(t time.Duration) ChunkedUploadOption

WithCommitTimeout return a wrapper option function to set commit timeout of the chunked upload instance

func WithEncrypt added in v1.2.88

func WithEncrypt(on bool) ChunkedUploadOption

WithEncrypt turn on/off encrypt on upload. It is turn off as default.

  • on: true to turn on, false to turn off

func WithEncryptedPoint added in v1.10.0

func WithEncryptedPoint(point string) ChunkedUploadOption

WithEncryptedKeyPoint return a wrapper option function to set encrypted key point of the chunked upload instance

func WithFileHasher added in v1.15.4

func WithFileHasher(h Hasher) ChunkedUploadOption

WithActualSize return a wrapper option function to set the file hasher used in the chunked upload instance

func WithMask added in v1.8.17

func WithMask(mask zboxutil.Uint128) ChunkedUploadOption

WithUploadMask return a wrapper option function to set upload mask of the chunked upload instance

func WithProgressStorer added in v1.3.6

func WithProgressStorer(progressStorer ChunkedUploadProgressStorer) ChunkedUploadOption

WithProgressCallback return a wrapper option function to set progress callback of the chunked upload instance

func WithStatusCallback added in v1.2.88

func WithStatusCallback(callback StatusCallback) ChunkedUploadOption

WithStatusCallback return a wrapper option function to set status callback of the chunked upload instance, which is used to track upload progress

  • callback: StatusCallback instance

func WithThumbnail added in v1.2.88

func WithThumbnail(buf []byte) ChunkedUploadOption

WithThumbnail add thumbnail. stream mode is unnecessary for thumbnail

func WithThumbnailFile added in v1.2.88

func WithThumbnailFile(fileName string) ChunkedUploadOption

WithThumbnailFile add thumbnail from file. stream mode is unnecessary for thumbnail.

  • fileName: file name of the thumbnail, which will be read and uploaded

func WithUploadTimeout added in v1.8.9

func WithUploadTimeout(t time.Duration) ChunkedUploadOption

WithUploadTimeout return a wrapper option function to set upload timeout of the chunked upload instance

type ChunkedUploadProgressStorer added in v1.2.88

type ChunkedUploadProgressStorer interface {
	// Load load upload progress by id
	Load(id string) *UploadProgress
	// Save save upload progress
	Save(up UploadProgress)
	// Remove remove upload progress by id
	Remove(id string) error
	// Update update upload progress
	Update(id string, chunkIndex int, upMask zboxutil.Uint128)
}

ChunkedUploadProgressStorer load and save upload progress

type CommitMetaData

type CommitMetaData struct {
	CrudType string
	MetaData *ConsolidatedFileMeta
}

type CommitMetaResponse

type CommitMetaResponse struct {
	TxnID    string
	MetaData *ConsolidatedFileMeta
}

type CommitRequest

type CommitRequest struct {
	ClientId string
	// contains filtered or unexported fields
}

type CommitRequestInterface added in v1.17.13

type CommitRequestInterface interface {
	// contains filtered or unexported methods
}

type CommitRequestV2 added in v1.17.13

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

type CommitResult

type CommitResult struct {
	Success      bool   `json:"success"`
	ErrorMessage string `json:"error_msg,omitempty"`
}

func ErrorCommitResult

func ErrorCommitResult(errMsg string) *CommitResult

func SuccessCommitResult

func SuccessCommitResult() *CommitResult

type Consensus

type Consensus struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

func (*Consensus) Done added in v1.2.88

func (c *Consensus) Done()

Done increase consensus by 1

func (*Consensus) Init added in v1.7.7

func (c *Consensus) Init(threshConsensus, fullConsensus int)

func (*Consensus) Reset added in v1.2.88

func (c *Consensus) Reset()

Reset reset consensus to 0

type ConsolidatedFileMeta

type ConsolidatedFileMeta struct {
	Name            string
	Type            string
	Path            string
	LookupHash      string
	Hash            string
	MimeType        string
	Size            int64
	NumBlocks       int64
	ActualFileSize  int64
	ActualNumBlocks int64
	EncryptedKey    string

	ActualThumbnailSize int64
	ActualThumbnailHash string

	Collaborators []fileref.Collaborator
}

ConsolidatedFileMeta represents the file meta data.

type ConsolidatedFileMetaByName added in v1.17.0

type ConsolidatedFileMetaByName struct {
	Name                string
	Type                string
	Path                string
	LookupHash          string
	Hash                string
	MimeType            string
	Size                int64
	NumBlocks           int64
	ActualFileSize      int64
	ActualNumBlocks     int64
	EncryptedKey        string
	FileMetaHash        string
	ThumbnailHash       string
	ActualThumbnailSize int64
	ActualThumbnailHash string
	Collaborators       []fileref.Collaborator
	CreatedAt           common.Timestamp
	UpdatedAt           common.Timestamp
}

type CopyOperation added in v1.8.17

type CopyOperation struct {
	Consensus
	// contains filtered or unexported fields
}

func NewCopyOperation added in v1.8.17

func NewCopyOperation(ctx context.Context, remotePath string, destPath string, copyMask zboxutil.Uint128, maskMU *sync.Mutex, consensusTh, fullConsensus int, copyDirOnly bool) *CopyOperation

func (*CopyOperation) Completed added in v1.8.17

func (co *CopyOperation) Completed(allocObj *Allocation)

func (*CopyOperation) Error added in v1.8.17

func (co *CopyOperation) Error(allocObj *Allocation, consensus int, err error)

func (*CopyOperation) GetLookupHash added in v1.17.13

func (co *CopyOperation) GetLookupHash(changeIndex uint64) []string

func (*CopyOperation) Process added in v1.8.17

func (co *CopyOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

func (*CopyOperation) ProcessChangeV2 added in v1.17.13

func (co *CopyOperation) ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error

func (*CopyOperation) Verify added in v1.8.17

func (co *CopyOperation) Verify(a *Allocation) error

type CopyRequest

type CopyRequest struct {
	Consensus
	// contains filtered or unexported fields
}

func (*CopyRequest) ProcessCopy

func (req *CopyRequest) ProcessCopy() error

func (*CopyRequest) ProcessWithBlobbers added in v1.8.17

func (req *CopyRequest) ProcessWithBlobbers() ([]fileref.RefEntity, error)

func (*CopyRequest) ProcessWithBlobbersV2 added in v1.17.13

func (req *CopyRequest) ProcessWithBlobbersV2() ([]fileref.RefEntity, error)

type CreateAllocationOptions added in v1.8.7

type CreateAllocationOptions struct {
	DataShards           int
	ParityShards         int
	Size                 int64
	ReadPrice            PriceRange
	WritePrice           PriceRange
	Lock                 uint64
	BlobberIds           []string
	BlobberAuthTickets   []string
	ThirdPartyExtendable bool
	IsEnterprise         bool
	FileOptionsParams    *FileOptionsParameters
	Force                bool
	StorageVersion       int
}

CreateAllocationOptions is used to specify the options for creating a new allocation.

type DataChan added in v1.8.17

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

Example implementation of a reader

type DeleteOperation added in v1.8.17

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

func NewDeleteOperation added in v1.8.17

func NewDeleteOperation(ctx context.Context, remotePath string, deleteMask zboxutil.Uint128, maskMu *sync.Mutex, consensusTh, fullConsensus int) *DeleteOperation

func (*DeleteOperation) Completed added in v1.8.17

func (dop *DeleteOperation) Completed(allocObj *Allocation)

func (*DeleteOperation) Error added in v1.8.17

func (dop *DeleteOperation) Error(allocObj *Allocation, consensus int, err error)

func (*DeleteOperation) GetLookupHash added in v1.17.13

func (dop *DeleteOperation) GetLookupHash(changeIndex uint64) []string

func (*DeleteOperation) Process added in v1.8.17

func (dop *DeleteOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

func (*DeleteOperation) ProcessChangeV2 added in v1.17.13

func (dop *DeleteOperation) ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error

func (*DeleteOperation) Verify added in v1.8.17

func (dop *DeleteOperation) Verify(a *Allocation) error

type DeleteRequest

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

func (*DeleteRequest) ProcessDelete

func (req *DeleteRequest) ProcessDelete() (err error)

type DirOperation added in v1.8.17

type DirOperation struct {
	Consensus
	// contains filtered or unexported fields
}

func NewDirOperation added in v1.8.17

func NewDirOperation(remotePath, customMeta string, dirMask zboxutil.Uint128, maskMU *sync.Mutex, consensusTh int, fullConsensus int, ctx context.Context) *DirOperation

func (*DirOperation) Completed added in v1.8.17

func (dirOp *DirOperation) Completed(allocObj *Allocation)

func (*DirOperation) Error added in v1.8.17

func (dirOp *DirOperation) Error(allocObj *Allocation, consensus int, err error)

func (*DirOperation) GetLookupHash added in v1.17.13

func (dirOp *DirOperation) GetLookupHash(changeIndex uint64) []string

func (*DirOperation) Process added in v1.8.17

func (dirOp *DirOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

func (*DirOperation) ProcessChangeV2 added in v1.17.13

func (dirOp *DirOperation) ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error

func (*DirOperation) Verify added in v1.8.17

func (dirOp *DirOperation) Verify(a *Allocation) error

type DirRequest

type DirRequest struct {
	Consensus
	// contains filtered or unexported fields
}

func (*DirRequest) ProcessDir

func (req *DirRequest) ProcessDir(a *Allocation) error

func (*DirRequest) ProcessWithBlobbers added in v1.8.17

func (req *DirRequest) ProcessWithBlobbers(a *Allocation) int

type DownloadOption added in v1.4.3

type DownloadOption func(do *DownloadOptions)

DownloadOption set download option

func WithAllocation added in v1.4.3

func WithAllocation(obj *Allocation) DownloadOption

WithAllocation set allocation object of the download option

func WithAuthticket added in v1.4.3

func WithAuthticket(authTicket, lookupHash string) DownloadOption

WithAuthTicket set auth ticket and lookup hash for the download request options This is used to download shared files.

  • authTicket: is the ticket that is generated by the owner of the file to access their shared file.
  • lookupHash: is an augmented hash of the allocation ID and the path of the file, used to locate the file.

func WithBlocks added in v1.4.3

func WithBlocks(start, end int64, blocksPerMarker int) DownloadOption

WithBlocks set block range for the download request options.

  • start: start block number
  • end: end block number
  • blocksPerMarker: number of blocks to download

func WithFileHandler added in v1.8.17

func WithFileHandler(fileHandler sys.File) DownloadOption

WithFileHandler set file handler for the download request options

func WithOnlyThumbnail added in v1.4.3

func WithOnlyThumbnail(thumbnail bool) DownloadOption

WithOnlyThumbnail set thumbnail download option which makes the request download only the thumbnail.

  • thumbnail: true to download only thumbnail, false to download the file.

func WithVerifyDownload added in v1.8.14

func WithVerifyDownload(shouldVerify bool) DownloadOption

WithVerifyDownload set verify download option for the download request options. If true, the response will contain proof of the download to be verified at the client side.

  • shouldVerify: true to verify download, false to not verify download.

type DownloadOptions added in v1.4.3

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

DownloadOptions download options

type DownloadProgress added in v1.13.0

type DownloadProgress struct {
	ID               string `json:"id"`
	LastWrittenBlock int    `json:"last_block"`
	// contains filtered or unexported fields
}

type DownloadProgressStorer added in v1.13.0

type DownloadProgressStorer interface {
	// Load load download progress by id
	Load(id string, numBlocks int) *DownloadProgress
	// Update download progress
	Update(writtenBlock int)
	// Remove remove download progress by id
	Remove() error
	// Start start download progress
	Start(ctx context.Context)
	// Save download progress
	Save(dp *DownloadProgress)
}

type DownloadRequest

type DownloadRequest struct {
	ClientId string

	Consensus
	// contains filtered or unexported fields
}

func (*DownloadRequest) Seek added in v1.8.17

func (req *DownloadRequest) Seek(offset int64, whence int) (int64, error)

type DownloadRequestHeader added in v1.7.2

type DownloadRequestHeader struct {
	ClientID       string
	PathHash       string
	BlockNum       int64
	NumBlocks      int64
	ReadMarker     []byte
	AuthToken      []byte
	DownloadMode   string
	VerifyDownload bool
	ConnectionID   string
	Version        string
}

DownloadRequestHeader download request header

func (*DownloadRequestHeader) ToFastHeader added in v1.13.0

func (h *DownloadRequestHeader) ToFastHeader(req *fasthttp.Request)

func (*DownloadRequestHeader) ToHeader added in v1.7.2

func (h *DownloadRequestHeader) ToHeader(req *http.Request)

ToHeader update header

type DownloadRequestOption added in v1.13.0

type DownloadRequestOption func(dr *DownloadRequest)

func WithDownloadProgressStorer added in v1.13.0

func WithDownloadProgressStorer(storer DownloadProgressStorer) DownloadRequestOption

WithDownloadProgressStorer set download progress storer of download request options.

  • storer: download progress storer instance, used to store download progress.

func WithFileCallback added in v1.13.0

func WithFileCallback(cb func()) DownloadRequestOption

func WithWorkDir added in v1.13.0

func WithWorkDir(workdir string) DownloadRequestOption

type Downloader added in v1.4.3

type Downloader interface {
	GetAllocation() *Allocation
	GetFileName() string
	Start(status StatusCallback, isFinal bool) error
}

Downloader downloader for file, blocks and thumbnail

func CreateDownloader added in v1.4.3

func CreateDownloader(allocationID, localPath, remotePath string, opts ...DownloadOption) (Downloader, error)

CreateDownloader create a downloander instance with options

  • allocationID: allocation id
  • localPath: local path to save the downloaded file
  • remotePath: remote path of the file to download
  • opts: download options as option functions

type FfmpegRecorder added in v1.2.88

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

FfmpegRecorder wrap ffmpeg command to capture video and audio from local camera and microphone

func CreateFfmpegRecorder added in v1.2.88

func CreateFfmpegRecorder(file string, delay int) (*FfmpegRecorder, error)

CreateFfmpegRecorder create a ffmpeg commander to capture video and audio local camera and microphone

  • file: output file path
  • delay: delay in seconds

func (*FfmpegRecorder) Close added in v1.2.88

func (r *FfmpegRecorder) Close() (err error)

Close implements io.Closer

func (*FfmpegRecorder) GetClipsFile added in v1.2.88

func (r *FfmpegRecorder) GetClipsFile(clipsIndex int) string

GetClipsFile get clips file

func (*FfmpegRecorder) GetClipsFileName added in v1.2.88

func (r *FfmpegRecorder) GetClipsFileName(clipsIndex int) string

GetClipsFileName get clips file name

func (*FfmpegRecorder) GetFileContentType added in v1.2.88

func (r *FfmpegRecorder) GetFileContentType() (string, error)

GetFileContentType get MIME type

func (*FfmpegRecorder) Read added in v1.2.88

func (r *FfmpegRecorder) Read(p []byte) (int, error)

Read implements io.Raader

func (*FfmpegRecorder) Size added in v1.2.88

func (r *FfmpegRecorder) Size() int64

Size get current clips size

type FileDiff

type FileDiff struct {
	Op   string `json:"operation"`
	Path string `json:"path"`
	Type string `json:"type"`
}

FileDiff file difference representation for sync

type FileInfo added in v1.8.13

type FileInfo struct {
	Size         int64            `json:"size"`
	MimeType     string           `json:"mimetype"`
	ActualSize   int64            `json:"actual_size"`
	Hash         string           `json:"hash"`
	Type         string           `json:"type"`
	EncryptedKey string           `json:"encrypted_key"`
	LookupHash   string           `json:"lookup_hash"`
	CreatedAt    common.Timestamp `json:"created_at"`
	UpdatedAt    common.Timestamp `json:"updated_at"`
}

FileInfo file information representation for sync

type FileMeta added in v1.0.3

type FileMeta struct {
	// Mimetype mime type of source file
	MimeType string

	// Path local path of source file
	Path string
	// ThumbnailPath local path of source thumbnail
	ThumbnailPath string

	// ActualHash hash of original file (un-encoded, un-encrypted)
	ActualHash string
	// ActualSize total bytes of  original file (unencoded, un-encrypted).  it is 0 if input is live stream.
	ActualSize int64
	// ActualThumbnailSize total bytes of original thumbnail (un-encoded, un-encrypted)
	ActualThumbnailSize int64
	// ActualThumbnailHash hash of original thumbnail (un-encoded, un-encrypted)
	ActualThumbnailHash string

	//RemoteName remote file name
	RemoteName string
	// RemotePath remote path
	RemotePath string
	// CustomMeta custom meta data
	CustomMeta string
}

FileMeta metadata of stream input/local

func TranscodeWebStreaming added in v1.8.16

func TranscodeWebStreaming(workdir string, fileReader io.Reader, fileMeta FileMeta) (io.Reader, *FileMeta, string, error)

Converting the video file to fmp4 format for web streaming

func (*FileMeta) FileID added in v1.2.88

func (meta *FileMeta) FileID() string

FileID generate id of progress on local cache

type FileNameBuilder added in v1.2.88

type FileNameBuilder interface {
	OutDir() string
	FileExt() string
	OutFile() string
	ClipsFile(index int) string
	ClipsFileName(index int) string
}

FileNameBuilder build file name based output format

type FileOptionParam added in v1.8.13

type FileOptionParam struct {
	Changed bool
	Value   bool
}

type FileOptionsParameters added in v1.8.13

type FileOptionsParameters struct {
	ForbidUpload FileOptionParam
	ForbidDelete FileOptionParam
	ForbidUpdate FileOptionParam
	ForbidMove   FileOptionParam
	ForbidCopy   FileOptionParam
	ForbidRename FileOptionParam
}

FileOptionsParameters is used to specify the file options parameters for an allocation, which control the usage permissions of the files in the allocation.

type FileStats

type FileStats struct {
	Name                     string    `json:"name"`
	Size                     int64     `json:"size"`
	PathHash                 string    `json:"path_hash"`
	Path                     string    `json:"path"`
	NumBlocks                int64     `json:"num_of_blocks"`
	NumUpdates               int64     `json:"num_of_updates"`
	NumBlockDownloads        int64     `json:"num_of_block_downloads"`
	SuccessChallenges        int64     `json:"num_of_challenges"`
	FailedChallenges         int64     `json:"num_of_failed_challenges"`
	LastChallengeResponseTxn string    `json:"last_challenge_txn"`
	WriteMarkerRedeemTxn     string    `json:"write_marker_txn"`
	BlobberID                string    `json:"blobber_id"`
	BlobberURL               string    `json:"blobber_url"`
	BlockchainAware          bool      `json:"blockchain_aware"`
	CreatedAt                time.Time `json:"CreatedAt"`
	FileID                   string    `json:"file_id"`
}

FileStats - file stats structure

type FsDownloadProgressStorer added in v1.13.0

type FsDownloadProgressStorer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func CreateFsDownloadProgress added in v1.13.0

func CreateFsDownloadProgress() *FsDownloadProgressStorer

CreateFsDownloadProgress create a download progress storer instance to track download progress and queue

func (*FsDownloadProgressStorer) Load added in v1.13.0

func (ds *FsDownloadProgressStorer) Load(progressID string, numBlocks int) *DownloadProgress

func (*FsDownloadProgressStorer) Remove added in v1.13.0

func (ds *FsDownloadProgressStorer) Remove() error

func (*FsDownloadProgressStorer) Save added in v1.13.0

func (*FsDownloadProgressStorer) Start added in v1.13.0

func (ds *FsDownloadProgressStorer) Start(ctx context.Context)

func (*FsDownloadProgressStorer) Update added in v1.13.0

func (ds *FsDownloadProgressStorer) Update(writtenBlock int)

type Hasher added in v1.2.88

type Hasher interface {
	// GetFileHash get file hash
	GetFileHash() (string, error)
	// WriteToFile write bytes to file hasher
	WriteToFile(buf []byte) error

	GetFixedMerkleRoot() (string, error)
	// WriteToFixedMT write bytes to FMT hasher
	WriteToFixedMT(buf []byte) error

	GetValidationRoot() (string, error)
	// WriteToValidationMT write bytes Validation Tree hasher
	WriteToValidationMT(buf []byte) error
	// Finalize will let merkle tree know that tree is finalized with the content it has received
	Finalize() error
}

Hasher interface to gather all hasher related functions. A hasher is used to calculate the hash of a file, fixed merkle tree, and validation merkle tree.

func CreateFileHasher added in v1.15.4

func CreateFileHasher() Hasher

func CreateHasher added in v1.2.88

func CreateHasher(dataSize int64) Hasher

CreateHasher creat Hasher instance

type LatestPrevWriteMarker added in v1.8.17

type LatestPrevWriteMarker struct {
	LatestWM *marker.WriteMarker `json:"latest_write_marker"`
	PrevWM   *marker.WriteMarker `json:"prev_write_marker"`
	Version  string              `json:"version"`
}

func GetWritemarker added in v1.8.17

func GetWritemarker(allocID, allocTx, sig, id, baseUrl string, clientId ...string) (*LatestPrevWriteMarker, error)

type ListRequest

type ListRequest struct {
	ClientId string

	Consensus
	// contains filtered or unexported fields
}

func (*ListRequest) GetListFromBlobbers

func (req *ListRequest) GetListFromBlobbers() (*ListResult, error)

type ListRequestOptions added in v1.12.1

type ListRequestOptions func(req *ListRequest)

func WithListRequestForRepair added in v1.12.1

func WithListRequestForRepair(forRepair bool) ListRequestOptions

func WithListRequestOffset added in v1.12.1

func WithListRequestOffset(offset int) ListRequestOptions

func WithListRequestPageLimit added in v1.12.1

func WithListRequestPageLimit(pageLimit int) ListRequestOptions

type ListResult

type ListResult struct {
	ClientId            string `json:"client_id"`
	Name                string `json:"name"`
	Path                string `json:"path,omitempty"`
	Type                string `json:"type"`
	Size                int64  `json:"size"`
	Hash                string `json:"hash,omitempty"`
	FileMetaHash        string `json:"file_meta_hash,omitempty"`
	MimeType            string `json:"mimetype,omitempty"`
	NumBlocks           int64  `json:"num_blocks"`
	LookupHash          string `json:"lookup_hash"`
	EncryptionKey       string `json:"encryption_key"`
	ActualSize          int64  `json:"actual_size"`
	ActualNumBlocks     int64  `json:"actual_num_blocks"`
	ThumbnailHash       string `json:"thumbnail_hash"`
	ThumbnailSize       int64  `json:"thumbnail_size"`
	ActualThumbnailHash string `json:"actual_thumbnail_hash"`
	ActualThumbnailSize int64  `json:"actual_thumbnail_size"`

	CreatedAt common.Timestamp `json:"created_at"`
	UpdatedAt common.Timestamp `json:"updated_at"`
	Children  []*ListResult    `json:"list"`
	Consensus `json:"-"`
	// contains filtered or unexported fields
}

ListResult a wrapper around the result of directory listing command. It can represent a file or a directory.

type LiveMeta added in v1.2.88

type LiveMeta struct {
	// Mimetype mime type of source file
	MimeType string

	//RemoteName remote file name
	RemoteName string
	// RemotePath remote path
	RemotePath string
}

LiveMeta metadata of live stream input

type LiveUpload added in v1.2.88

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

LiveUpload live streaming video upload manager

func CreateLiveUpload added in v1.2.88

func CreateLiveUpload(homedir string, allocationObj *Allocation, liveMeta LiveMeta, liveReader LiveUploadReader, opts ...LiveUploadOption) *LiveUpload

CreateLiveUpload create a LiveChunkedUpload instance to upload live streaming video

  • homedir: home directory of the allocation
  • allocationObj: allocation object
  • liveMeta: live meta data
  • liveReader: live reader to read video data
  • opts: live upload option functions which customize the LiveUpload instance.

func (*LiveUpload) Start added in v1.2.88

func (lu *LiveUpload) Start() error

Start start live streaming upload

type LiveUploadOption added in v1.2.88

type LiveUploadOption func(lu *LiveUpload)

LiveUploadOption set live upload option

func WithLiveChunkNumber added in v1.7.7

func WithLiveChunkNumber(num int) LiveUploadOption

WithLiveChunkNumber set the number of chunks should be upload in a live upload request. Ignore if size <=0.

  • num: number of chunks

func WithLiveDelay added in v1.2.88

func WithLiveDelay(delaySeconds int) LiveUploadOption

WithLiveDelay set number of seconds to wait before starting the live upload. Ignore if less than 0.

  • delaySeconds: number of seconds

func WithLiveEncrypt added in v1.2.88

func WithLiveEncrypt(status bool) LiveUploadOption

WithLiveEncrypt trun on/off encrypt on upload. It is turned off by default.

  • status: true to turn on, false to turn off

func WithLiveStatusCallback added in v1.2.88

func WithLiveStatusCallback(callback func() StatusCallback) LiveUploadOption

WithLiveStatusCallback register StatusCallback instance to track live upload progress

  • callback: StatusCallback instance

type LiveUploadReader added in v1.2.88

type LiveUploadReader interface {
	io.Reader
	Size() int64
	GetClipsFile(clipsIndex int) string
	GetClipsFileName(cliipsIndex int) string
}

LiveUploadReader implements io.Reader and Size for live stream upload

type M3u8Writer added in v1.2.88

type M3u8Writer interface {
	io.WriteSeeker
	Truncate(size int64) error
	Sync() error
}

M3u8Writer m3u8 writer

type MediaPlaylist added in v1.2.88

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

MediaPlaylist queue-based m3u8 playlist

func NewMediaPlaylist added in v1.2.88

func NewMediaPlaylist(delay int, dir string, writer M3u8Writer) *MediaPlaylist

NewMediaPlaylist create media playlist(.m3u8)

func (*MediaPlaylist) Append added in v1.2.88

func (m *MediaPlaylist) Append(item string)

Append append new item into playlist

func (*MediaPlaylist) Encode added in v1.2.88

func (m *MediaPlaylist) Encode() []byte

Encode encode m3u8

func (*MediaPlaylist) Play added in v1.2.88

func (m *MediaPlaylist) Play()

Play start to play the contents of the playlist with 1 second buffer between each item

func (*MediaPlaylist) String added in v1.2.88

func (m *MediaPlaylist) String() string

String implement Stringer

type MoveOperation added in v1.8.17

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

func NewMoveOperation added in v1.8.17

func NewMoveOperation(remotePath string, destPath string, moveMask zboxutil.Uint128, maskMU *sync.Mutex, consensusTh int, fullConsensus int, ctx context.Context) *MoveOperation

func (*MoveOperation) Completed added in v1.8.17

func (mo *MoveOperation) Completed(allocObj *Allocation)

func (*MoveOperation) Error added in v1.8.17

func (mo *MoveOperation) Error(allocObj *Allocation, consensus int, err error)

func (*MoveOperation) GetLookupHash added in v1.17.13

func (mo *MoveOperation) GetLookupHash(changeIndex uint64) []string

func (*MoveOperation) Process added in v1.8.17

func (mo *MoveOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

func (*MoveOperation) ProcessChangeV2 added in v1.17.13

func (mo *MoveOperation) ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error

func (*MoveOperation) Verify added in v1.8.17

func (mo *MoveOperation) Verify(a *Allocation) error

type MoveRequest added in v1.8.10

type MoveRequest struct {
	Consensus
	// contains filtered or unexported fields
}

func (*MoveRequest) ProcessMove added in v1.8.10

func (req *MoveRequest) ProcessMove() error

func (*MoveRequest) ProcessWithBlobbers added in v1.8.17

func (req *MoveRequest) ProcessWithBlobbers() ([]fileref.RefEntity, error)

func (*MoveRequest) ProcessWithBlobbersV2 added in v1.17.13

func (req *MoveRequest) ProcessWithBlobbersV2() ([]fileref.RefEntity, error)

type MultiOperation added in v1.8.17

type MultiOperation struct {
	Consensus
	// contains filtered or unexported fields
}

func (*MultiOperation) Process added in v1.8.17

func (mo *MultiOperation) Process() error

type MultiOperationOption added in v1.11.4

type MultiOperationOption func(mo *MultiOperation)

func WithRepair added in v1.11.4

func WithRepair() MultiOperationOption

type ORef added in v1.3.0

type ORef struct {
	SimilarField
	ID        int64            `json:"id"`
	CreatedAt common.Timestamp `json:"created_at"`
	UpdatedAt common.Timestamp `json:"updated_at"`
	Err       error            `json:"-"`
}

Blobber response will be different from each other so we should only consider similar fields i.e. we cannot calculate hash of response and have consensus on it

type ObjectTreeRequest added in v1.3.0

type ObjectTreeRequest struct {
	ClientId string

	Consensus
	// contains filtered or unexported fields
}

func (*ObjectTreeRequest) GetRefs added in v1.3.0

func (o *ObjectTreeRequest) GetRefs() (*ObjectTreeResult, error)

Paginated tree should not be collected as this will stall the client It should rather be handled by application that uses gosdk

type ObjectTreeRequestOption added in v1.17.13

type ObjectTreeRequestOption func(*ObjectTreeRequest)

func WithObjectConsensusThresh added in v1.17.13

func WithObjectConsensusThresh(thresh int) ObjectTreeRequestOption

func WithObjectContext added in v1.17.13

func WithObjectContext(ctx context.Context) ObjectTreeRequestOption

func WithObjectMask added in v1.17.13

func WithObjectMask(mask zboxutil.Uint128) ObjectTreeRequestOption

func WithSingleBlobber added in v1.17.13

func WithSingleBlobber(singleBlobber bool) ObjectTreeRequestOption

type ObjectTreeResult added in v1.3.0

type ObjectTreeResult struct {
	TotalPages int64               `json:"total_pages"`
	OffsetPath string              `json:"offset_path"`
	OffsetDate string              `json:"offset_date"`
	Refs       []ORef              `json:"refs"`
	LatestWM   *marker.WriteMarker `json:"latest_write_marker"`
}

type OperationRequest added in v1.8.17

type OperationRequest struct {
	OperationType  string
	LocalPath      string
	RemotePath     string
	DestName       string // Required only for rename operation
	DestPath       string // Required for copy and move operation
	IsUpdate       bool
	IsRepair       bool // Required for repair operation
	IsWebstreaming bool
	EncryptedKey   string

	// Required for uploads
	Workdir         string
	FileMeta        FileMeta
	FileReader      io.Reader
	Mask            *zboxutil.Uint128 // Required for delete repair operation
	DownloadFile    bool              // Required for upload repair operation
	StreamUpload    bool              // Required for streaming file when actualSize is not available
	CancelCauseFunc context.CancelCauseFunc
	Opts            []ChunkedUploadOption
	CopyDirOnly     bool
}

OperationRequest represents an operation request with its related options.

type Operationer added in v1.8.17

type Operationer interface {
	Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

	Verify(allocObj *Allocation) error
	Completed(allocObj *Allocation)
	Error(allocObj *Allocation, consensus int, err error)
	ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error
	GetLookupHash(changeIndex uint64) []string
	// contains filtered or unexported methods
}

type PlaylistFile added in v1.8.8

type PlaylistFile struct {
	LookupHash     string `gorm:"column:lookup_hash" json:"lookup_hash"`
	Name           string `gorm:"column:name" json:"name"`
	Path           string `gorm:"column:path" json:"path"`
	NumBlocks      int64  `gorm:"column:num_of_blocks" json:"num_of_blocks"`
	ParentPath     string `gorm:"column:parent_path" json:"parent_path"`
	Size           int64  `gorm:"column:size;" json:"size"`
	ActualFileSize int64
	MimeType       string `gorm:"column:mimetype" json:"mimetype"`
	Type           string `gorm:"column:type" json:"type"`
}

func GetPlaylist added in v1.8.8

func GetPlaylist(ctx context.Context, alloc *Allocation, path, since string) ([]PlaylistFile, error)

func GetPlaylistByAuthTicket added in v1.8.8

func GetPlaylistByAuthTicket(ctx context.Context, alloc *Allocation, authTicket, lookupHash, since string) ([]PlaylistFile, error)

func GetPlaylistFile added in v1.8.8

func GetPlaylistFile(ctx context.Context, alloc *Allocation, path string) (*PlaylistFile, error)

func GetPlaylistFileByAuthTicket added in v1.8.8

func GetPlaylistFileByAuthTicket(ctx context.Context, alloc *Allocation, authTicket, lookupHash string) (*PlaylistFile, error)

type PriceRange

type PriceRange struct {
	Min uint64 `json:"min"`
	Max uint64 `json:"max"`
}

PriceRange represents a price range allowed by user to filter blobbers.

func GetReadPriceRange added in v1.8.16

func GetReadPriceRange() (PriceRange, error)

GetReadPriceRange returns the read price range from the global configuration.

func GetWritePriceRange added in v1.8.16

func GetWritePriceRange() (PriceRange, error)

GetWritePriceRange returns the write price range from the global configuration.

func (*PriceRange) IsValid

func (pr *PriceRange) IsValid() bool

IsValid price range.

type ProcessResult added in v1.8.9

type ProcessResult struct {
	BlobberIndex int
	FileRef      fileref.RefEntity
	Succeed      bool
}

type ProviderType added in v1.7.1

type ProviderType int

ProviderType is the type of the provider.

const (
	ProviderMiner ProviderType = iota + 1
	ProviderSharder
	ProviderBlobber
	ProviderValidator
	ProviderAuthorizer
)

type RecentlyAddedRefRequest added in v1.8.7

type RecentlyAddedRefRequest struct {
	ClientId string

	Consensus
	// contains filtered or unexported fields
}

func (*RecentlyAddedRefRequest) GetRecentlyAddedRefs added in v1.8.7

func (r *RecentlyAddedRefRequest) GetRecentlyAddedRefs() (*RecentlyAddedRefResult, error)

type RecentlyAddedRefResponse added in v1.8.7

type RecentlyAddedRefResponse struct {
	Result *RecentlyAddedRefResult
	// contains filtered or unexported fields
}

type RecentlyAddedRefResult added in v1.8.7

type RecentlyAddedRefResult struct {
	Offset int    `json:"offset"`
	Refs   []ORef `json:"refs"`
}

type ReferencePathResult

type ReferencePathResult struct {
	*fileref.ReferencePath
	LatestWM *marker.WriteMarker `json:"latest_write_marker"`
	Version  string              `json:"version"`
}

type ReferencePathResultV2 added in v1.17.13

type ReferencePathResultV2 struct {
	Path     []byte              `json:"path"`
	LatestWM *marker.WriteMarker `json:"latest_write_marker"`
	Version  string              `json:"version"`
}

type RenameOperation added in v1.8.17

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

func NewRenameOperation added in v1.8.17

func NewRenameOperation(remotePath string, destName string, renameMask zboxutil.Uint128, maskMU *sync.Mutex, consensusTh int, fullConsensus int, ctx context.Context) *RenameOperation

func (*RenameOperation) Completed added in v1.8.17

func (ro *RenameOperation) Completed(allocObj *Allocation)

func (*RenameOperation) Error added in v1.8.17

func (ro *RenameOperation) Error(allocObj *Allocation, consensus int, err error)

func (*RenameOperation) GetLookupHash added in v1.17.13

func (ro *RenameOperation) GetLookupHash(changeIndex uint64) []string

func (*RenameOperation) Process added in v1.8.17

func (ro *RenameOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

func (*RenameOperation) ProcessChangeV2 added in v1.17.13

func (ro *RenameOperation) ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error

func (*RenameOperation) Verify added in v1.8.17

func (ro *RenameOperation) Verify(a *Allocation) error

type RenameRequest

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

func (*RenameRequest) ProcessRename

func (req *RenameRequest) ProcessRename() error

func (*RenameRequest) ProcessWithBlobbers added in v1.8.17

func (req *RenameRequest) ProcessWithBlobbers() ([]fileref.RefEntity, error)

func (*RenameRequest) ProcessWithBlobbersV2 added in v1.17.13

func (req *RenameRequest) ProcessWithBlobbersV2() ([]fileref.RefEntity, error)

type RepairRequest

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

func (*RepairRequest) Size added in v1.16.0

func (r *RepairRequest) Size(ctx context.Context, dir *ListResult) (RepairSize, error)

gets size to repair for remote dir.

type RepairSize added in v1.16.0

type RepairSize struct {
	// upload size in bytes
	UploadSize uint64 `json:"upload_size"`
	// download size in bytes
	DownloadSize uint64 `json:"download_size"`
}

holds result of repair size

type RepairStatusCB

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

func (*RepairStatusCB) Completed

func (cb *RepairStatusCB) Completed(allocationId, filePath string, filename string, mimetype string, size int, op int)

func (*RepairStatusCB) Error

func (cb *RepairStatusCB) Error(allocationID string, filePath string, op int, err error)

func (*RepairStatusCB) InProgress

func (cb *RepairStatusCB) InProgress(allocationId, filePath string, op int, completedBytes int, data []byte)

func (*RepairStatusCB) RepairCompleted

func (cb *RepairStatusCB) RepairCompleted(filesRepaired int)

func (*RepairStatusCB) Started

func (cb *RepairStatusCB) Started(allocationId, filePath string, op int, totalBytes int)

type ResetBlobberStatsDto added in v1.13.0

type ResetBlobberStatsDto struct {
	BlobberID     string `json:"blobber_id"`
	PrevAllocated int64  `json:"prev_allocated"`
	PrevSavedData int64  `json:"prev_saved_data"`
	NewAllocated  int64  `json:"new_allocated"`
	NewSavedData  int64  `json:"new_saved_data"`
}

ResetBlobberStatsDto represents blobber stats reset request.

type RollbackBlobber added in v1.8.17

type RollbackBlobber struct {
	ClientId string
	// contains filtered or unexported fields
}

type ShareRequest

type ShareRequest struct {
	ClientId string
	// contains filtered or unexported fields
}

func (*ShareRequest) GetFileRef

func (req *ShareRequest) GetFileRef() (*fileref.FileRef, error)

type SignalContext added in v1.3.0

type SignalContext struct {
	context.Context
}

SignalContext listen syscall signal to cancel context

type SimilarField added in v1.3.0

type SimilarField struct {
	FileID              string `json:"file_id"`
	FileMetaHash        string `json:"file_meta_hash"`
	Type                string `json:"type"`
	AllocationID        string `json:"allocation_id"`
	LookupHash          string `json:"lookup_hash"`
	Name                string `json:"name"`
	Path                string `json:"path"`
	PathHash            string `json:"path_hash"`
	ParentPath          string `json:"parent_path"`
	PathLevel           int    `json:"level"`
	Size                int64  `json:"size"`
	EncryptedKey        string `json:"encrypted_key"`
	EncryptedKeyPoint   string `json:"encrypted_key_point"`
	ActualFileSize      int64  `json:"actual_file_size"`
	ActualFileHash      string `json:"actual_file_hash"`
	MimeType            string `json:"mimetype"`
	ActualThumbnailSize int64  `json:"actual_thumbnail_size"`
	ActualThumbnailHash string `json:"actual_thumbnail_hash"`
	CustomMeta          string `json:"custom_meta"`
}

type StakePoolDelegatePoolInfo

type StakePoolDelegatePoolInfo struct {
	ID         common.Key     `json:"id"`          // blobber ID
	Balance    common.Balance `json:"balance"`     // current balance
	DelegateID common.Key     `json:"delegate_id"` // wallet
	Rewards    common.Balance `json:"rewards"`     // current
	UnStake    bool           `json:"unstake"`     // want to unstake

	TotalReward  common.Balance   `json:"total_reward"`
	TotalPenalty common.Balance   `json:"total_penalty"`
	Status       string           `json:"status"`
	RoundCreated int64            `json:"round_created"`
	StakedAt     common.Timestamp `json:"staked_at"`
}

StakePoolDelegatePoolInfo represents delegate pool of a stake pool info.

type StakePoolInfo

type StakePoolInfo struct {
	ID         common.Key     `json:"pool_id"` // pool ID
	Balance    common.Balance `json:"balance"` // total balance
	StakeTotal common.Balance `json:"stake_total"`
	// delegate pools
	Delegate []StakePoolDelegatePoolInfo `json:"delegate"`
	// rewards
	Rewards common.Balance `json:"rewards"`
	// total rewards
	TotalRewards common.Balance `json:"total_rewards"`
	// Settings of the stake pool
	Settings blockchain.StakePoolSettings `json:"settings"`
}

StakePool information of stake pool of a provider.

func GetStakePoolInfo

func GetStakePoolInfo(providerType ProviderType, providerID string) (info *StakePoolInfo, err error)

GetStakePoolInfo retrieve stake pool info for the current client configured to the sdk, given provider type and provider ID.

  • providerType: provider type
  • providerID: provider ID

type StakePoolOfferInfo

type StakePoolOfferInfo struct {
	Lock         common.Balance   `json:"lock"`
	Expire       common.Timestamp `json:"expire"`
	AllocationID common.Key       `json:"allocation_id"`
	IsExpired    bool             `json:"is_expired"`
}

StakePoolOfferInfo represents stake pool offer information.

type StakePoolRewardsInfo

type StakePoolRewardsInfo struct {
	Charge    common.Balance `json:"charge"`    // total for all time
	Blobber   common.Balance `json:"blobber"`   // total for all time
	Validator common.Balance `json:"validator"` // total for all time
}

StakePoolRewardsInfo represents stake pool rewards.

type StakePoolUserInfo

type StakePoolUserInfo struct {
	Pools map[common.Key][]*StakePoolDelegatePoolInfo `json:"pools"`
}

StakePoolUserInfo represents user stake pools statistic.

func GetStakePoolUserInfo

func GetStakePoolUserInfo(clientID string, offset, limit int) (info *StakePoolUserInfo, err error)

GetStakePoolUserInfo obtains blobbers/validators delegate pools statistic for a user. If given clientID is empty string, then current client used.

  • clientID: client ID
  • offset: offset
  • limit: limit

type StatusBar added in v1.2.1

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

func NewRepairBar added in v1.8.17

func NewRepairBar(allocID string) *StatusBar

func (*StatusBar) CheckError added in v1.15.0

func (s *StatusBar) CheckError() error

func (*StatusBar) Completed added in v1.2.1

func (s *StatusBar) Completed(allocationId, filePath string, filename string, mimetype string, size int, op int)

func (*StatusBar) Error added in v1.2.1

func (s *StatusBar) Error(allocationID string, filePath string, op int, err error)

func (*StatusBar) InProgress added in v1.2.1

func (s *StatusBar) InProgress(allocationId, filePath string, op int, completedBytes int, data []byte)

func (*StatusBar) RepairCompleted added in v1.2.1

func (s *StatusBar) RepairCompleted(filesRepaired int)

func (*StatusBar) Started added in v1.2.1

func (s *StatusBar) Started(allocationId, filePath string, op int, totalBytes int)

func (*StatusBar) Wait added in v1.15.0

func (s *StatusBar) Wait()

type StatusCallback

type StatusCallback interface {
	Started(allocationId, filePath string, op int, totalBytes int)
	InProgress(allocationId, filePath string, op int, completedBytes int, data []byte)
	Error(allocationID string, filePath string, op int, err error)
	Completed(allocationId, filePath string, filename string, mimetype string, size int, op int)
	RepairCompleted(filesRepaired int)
}

type StorageNodeIdField added in v1.17.13

type StorageNodeIdField struct {
	Id string `json:"id"`
}

type StreamDownload added in v1.8.16

type StreamDownload struct {
	*DownloadRequest
	// contains filtered or unexported fields
}

func (*StreamDownload) Close added in v1.8.16

func (sd *StreamDownload) Close() error

func (*StreamDownload) Read added in v1.8.16

func (sd *StreamDownload) Read(b []byte) (int, error)

func (*StreamDownload) Seek added in v1.8.16

func (sd *StreamDownload) Seek(offset int64, whence int) (int64, error)

type StreamDownloadOption added in v1.8.16

type StreamDownloadOption struct {
	ContentMode     string
	AuthTicket      string
	BlocksPerMarker uint // Number of blocks to download per request
	VerifyDownload  bool // Verify downloaded data against ValidaitonRoot.
}

type StreamReader added in v1.8.17

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

func NewStreamReader added in v1.8.17

func NewStreamReader(dataChan chan *DataChan) *StreamReader

func (*StreamReader) Read added in v1.8.17

func (r *StreamReader) Read(p []byte) (int, error)

Client should always send bytes equal to less than chunkDataSizePerRead

type Terms

type Terms struct {
	ReadPrice        common.Balance `json:"read_price"`  // tokens / GB
	WritePrice       common.Balance `json:"write_price"` // tokens / GB
	MaxOfferDuration time.Duration  `json:"max_offer_duration"`
}

Terms represents Blobber terms. A Blobber can update its terms, but any existing offer will use terms of offer signing time.

type UpdateBlobber added in v1.8.17

type UpdateBlobber struct {
	ID                       common.Key                          `json:"id"`
	BaseURL                  *string                             `json:"url,omitempty"`
	Terms                    *UpdateTerms                        `json:"terms,omitempty"`
	Capacity                 *common.Size                        `json:"capacity,omitempty"`
	Allocated                *common.Size                        `json:"allocated,omitempty"`
	LastHealthCheck          *common.Timestamp                   `json:"last_health_check,omitempty"`
	StakePoolSettings        *blockchain.UpdateStakePoolSettings `json:"stake_pool_settings,omitempty"`
	TotalStake               *int64                              `json:"total_stake,omitempty"`
	UsedAllocation           *int64                              `json:"used_allocation,omitempty"`
	TotalOffers              *int64                              `json:"total_offers,omitempty"`
	TotalServiceCharge       *int64                              `json:"total_service_charge,omitempty"`
	UncollectedServiceCharge *int64                              `json:"uncollected_service_charge,omitempty"`
	IsKilled                 *bool                               `json:"is_killed,omitempty"`
	IsShutdown               *bool                               `json:"is_shutdown,omitempty"`
	NotAvailable             *bool                               `json:"not_available,omitempty"`
	IsRestricted             *bool                               `json:"is_restricted,omitempty"`
	StorageVersion           *int                                `json:"storage_version,omitempty"`
	DelegateWallet           *string                             `json:"delegate_wallet,omitempty"`
}

UpdateBlobber is used during update blobber settings calls. Note the types are of pointer types with omitempty json property. This is done to correctly identify which properties are actually changing.

type UpdateTerms added in v1.8.17

type UpdateTerms struct {
	ReadPrice        *common.Balance `json:"read_price,omitempty"`  // tokens / GB
	WritePrice       *common.Balance `json:"write_price,omitempty"` // tokens / GB
	MaxOfferDuration *time.Duration  `json:"max_offer_duration,omitempty"`
}

UpdateTerms represents Blobber terms during update blobber calls. A Blobber can update its terms, but any existing offer will use terms of offer signing time.

type UpdateValidator added in v1.8.17

type UpdateValidator struct {
	ID                       common.Key        `json:"validator_id"`
	BaseURL                  *string           `json:"url,omitempty"`
	DelegateWallet           *string           `json:"delegate_wallet,omitempty"`
	MinStake                 *common.Balance   `json:"min_stake,omitempty"`
	MaxStake                 *common.Balance   `json:"max_stake,omitempty"`
	NumDelegates             *int              `json:"num_delegates,omitempty"`
	ServiceCharge            *float64          `json:"service_charge,omitempty"`
	StakeTotal               *int64            `json:"stake_total,omitempty"`
	TotalServiceCharge       *int64            `json:"total_service_charge,omitempty"`
	UncollectedServiceCharge *int64            `json:"uncollected_service_charge,omitempty"`
	LastHealthCheck          *common.Timestamp `json:"last_health_check,omitempty"`
	IsKilled                 *bool             `json:"is_killed,omitempty"`
	IsShutdown               *bool             `json:"is_shutdown,omitempty"`
}

UpdateValidator is used during update validator settings calls. Note the types are of pointer types with omitempty json property. This is done to correctly identify which properties are actually changing.

func (*UpdateValidator) ConvertToValidationNode added in v1.8.17

func (v *UpdateValidator) ConvertToValidationNode() *blockchain.UpdateValidationNode

ConvertToValidationNode converts UpdateValidator request to blockchain.UpdateValidationNode.

type UploadBlobberStatus added in v1.2.88

type UploadBlobberStatus struct {
	Hasher Hasher

	// UploadLength total bytes that has been uploaded to blobbers
	UploadLength int64 `json:"upload_length,omitempty"`
}

UploadBlobberStatus the status of blobber's upload progress

func (*UploadBlobberStatus) UnmarshalJSON added in v1.5.2

func (s *UploadBlobberStatus) UnmarshalJSON(b []byte) error

type UploadData added in v1.11.0

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

type UploadFileMeta

type UploadFileMeta struct {
	// Name remote file name
	Name string
	// Path remote path
	Path string
	// Hash hash of entire source file
	Hash     string
	MimeType string
	// Size total bytes of entire source file
	Size int64

	// ThumbnailSize total bytes of entire thumbnail
	ThumbnailSize int64
	// ThumbnailHash hash code of entire thumbnail
	ThumbnailHash string
}

type UploadFormData added in v1.2.88

type UploadFormData struct {
	ConnectionID string `json:"connection_id,omitempty"`
	// Filename remote file name
	Filename string `json:"filename,omitempty"`
	// Path remote path
	Path string `json:"filepath,omitempty"`

	// ValidationRoot is merkle root of sha256 of 64KB as leaf
	ValidationRoot          string `json:"validation_root,omitempty"`
	ValidationRootSignature string `json:"validation_root_signature,omitempty"`
	// Hash hash of shard thumbnail  (encoded,encrypted)
	ThumbnailContentHash string `json:"thumbnail_content_hash,omitempty"`

	// ChallengeHash challenge hash of shard data (encoded, encrypted)
	FixedMerkleRoot string `json:"fixed_merkle_root,omitempty"`

	// ActualHash hash of original file (un-encoded, un-encrypted)
	ActualHash              string `json:"actual_hash,omitempty"`
	ActualFileHashSignature string `json:"actual_file_hash_signature,omitempty"`
	// ActualSize total bytes of original file (un-encoded, un-encrypted)
	ActualSize int64 `json:"actual_size,omitempty"`
	// ActualThumbnailSize total bytes of original thumbnail (un-encoded, un-encrypted)
	ActualThumbSize int64 `json:"actual_thumb_size,omitempty"`
	// ActualThumbnailHash hash of original thumbnail (un-encoded, un-encrypted)
	ActualThumbHash string `json:"actual_thumb_hash,omitempty"`

	MimeType          string `json:"mimetype,omitempty"`
	CustomMeta        string `json:"custom_meta,omitempty"`
	EncryptedKey      string `json:"encrypted_key,omitempty"`
	EncryptedKeyPoint string `json:"encrypted_key_point,omitempty"`

	IsFinal          bool  `json:"is_final,omitempty"`          // all of chunks are uploaded
	ChunkStartIndex  int   `json:"chunk_start_index,omitempty"` // start index of chunks.
	ChunkEndIndex    int   `json:"chunk_end_index,omitempty"`   // end index of chunks. all chunks MUST be uploaded one by one because of streaming merkle hash
	ChunkSize        int64 `json:"chunk_size,omitempty"`        // the size of a chunk. 64*1024 is default
	UploadOffset     int64 `json:"upload_offset,omitempty"`     // It is next position that new incoming chunk should be append to
	Size             int64 `json:"size"`                        // total size of shard
	SignatureVersion int   `json:"signature_version,omitempty"`
}

UploadFormData form data of upload

type UploadMode added in v1.14.0

type UploadMode byte
const (
	UploadModeLow UploadMode = iota
	UploadModeMedium
	UploadModeHigh
)

type UploadOperation added in v1.8.17

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

func NewUploadOperation added in v1.8.17

func NewUploadOperation(ctx context.Context, workdir string, allocObj *Allocation, connectionID string, fileMeta FileMeta, fileReader io.Reader, isUpdate, isWebstreaming, isRepair, isMemoryDownload, isStreamUpload bool, opts ...ChunkedUploadOption) (*UploadOperation, string, error)

func (*UploadOperation) Completed added in v1.8.17

func (uo *UploadOperation) Completed(allocObj *Allocation)

func (*UploadOperation) Error added in v1.8.17

func (uo *UploadOperation) Error(allocObj *Allocation, consensus int, err error)

func (*UploadOperation) GetLookupHash added in v1.17.13

func (uo *UploadOperation) GetLookupHash(changeIndex uint64) []string

func (*UploadOperation) Process added in v1.8.17

func (uo *UploadOperation) Process(allocObj *Allocation, connectionID string) ([]fileref.RefEntity, zboxutil.Uint128, error)

func (*UploadOperation) ProcessChangeV2 added in v1.17.13

func (uo *UploadOperation) ProcessChangeV2(trie *wmpt.WeightedMerkleTrie, changeIndex uint64) error

func (*UploadOperation) Verify added in v1.8.17

func (uo *UploadOperation) Verify(allocationObj *Allocation) error

type UploadProgress added in v1.2.88

type UploadProgress struct {
	ID string `json:"id"`
	// Lat updated time
	LastUpdated common.Timestamp `json:"last_updated,omitempty"`
	// ChunkSize size of chunk
	ChunkSize   int64 `json:"chunk_size,omitempty"`
	ActualSize  int64 `json:"actual_size,omitempty"`
	ChunkNumber int   `json:"chunk_number,omitempty"`
	// EncryptOnUpload encrypt data on upload or not
	EncryptOnUpload   bool   `json:"is_encrypted,omitempty"`
	EncryptPrivateKey string `json:"-"`
	EncryptedKeyPoint string `json:"encrypted_key_point,omitempty"`

	// ConnectionID chunked upload connection_id
	ConnectionID string `json:"connection_id,omitempty"`
	// ChunkIndex index of last updated chunk
	ChunkIndex int `json:"chunk_index,omitempty"`
	// UploadLength total bytes that has been uploaded to blobbers
	UploadLength int64 `json:"-"`
	// ReadLength total bytes that has been read from original reader (un-encoded, un-encrypted)
	ReadLength int64            `json:"-"`
	UploadMask zboxutil.Uint128 `json:"upload_mask"`

	Blobbers []*UploadBlobberStatus `json:"-"`
}

UploadProgress progress of upload

type UploadResult added in v1.2.88

type UploadResult struct {
	Filename   string `json:"filename"`
	ShardSize  int64  `json:"size"`
	Hash       string `json:"content_hash,omitempty"`
	MerkleRoot string `json:"merkle_root,omitempty"`
}

type Validator added in v1.8.5

type Validator struct {
	ID                       common.Key       `json:"validator_id"`
	BaseURL                  string           `json:"url"`
	PublicKey                string           `json:"-"`
	DelegateWallet           string           `json:"delegate_wallet"`
	MinStake                 common.Balance   `json:"min_stake"`
	MaxStake                 common.Balance   `json:"max_stake"`
	NumDelegates             int              `json:"num_delegates"`
	ServiceCharge            float64          `json:"service_charge"`
	StakeTotal               int64            `json:"stake_total"`
	TotalServiceCharge       int64            `json:"total_service_charge"`
	UncollectedServiceCharge int64            `json:"uncollected_service_charge"`
	LastHealthCheck          common.Timestamp `json:"last_health_check"`
	IsKilled                 bool             `json:"is_killed"`
	IsShutdown               bool             `json:"is_shutdown"`
}

Validator represents validator information.

func GetValidator added in v1.8.5

func GetValidator(validatorID string) (validator *Validator, err error)

GetValidator retrieve validator instance by id.

  • validatorID: the id of validator

func GetValidators added in v1.8.5

func GetValidators(stakable bool) (validators []*Validator, err error)

GetValidators returns list of validators.

  • stakable: if true then only stakable validators are returned

type WMLockResult added in v1.7.3

type WMLockResult struct {
	Status    WMLockStatus `json:"status,omitempty"`
	CreatedAt int64        `json:"created_at,omitempty"`
}

type WMLockStatus added in v1.7.3

type WMLockStatus int
const (
	WMLockStatusFailed WMLockStatus = iota
	WMLockStatusPending
	WMLockStatusOK
)

type WriteMarkerMutex added in v1.7.3

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

WriteMarkerMutex blobber WriteMarkerMutex client

func CreateWriteMarkerMutex added in v1.7.3

func CreateWriteMarkerMutex(allocationObj *Allocation) (*WriteMarkerMutex, error)

CreateWriteMarkerMutex create WriteMarkerMutex for allocation

func (*WriteMarkerMutex) Lock added in v1.7.3

func (wmMu *WriteMarkerMutex) Lock(
	ctx context.Context, mask *zboxutil.Uint128,
	maskMu *sync.Mutex, blobbers []*blockchain.StorageNode,
	consensus *Consensus, addConsensus int, timeOut time.Duration, connID string) error

func (*WriteMarkerMutex) Unlock added in v1.7.3

func (wmMu *WriteMarkerMutex) Unlock(
	ctx context.Context, mask zboxutil.Uint128,
	blobbers []*blockchain.StorageNode,
	timeOut time.Duration, connID string,
)

func (*WriteMarkerMutex) UnlockBlobber added in v1.8.9

func (wmMu *WriteMarkerMutex) UnlockBlobber(
	ctx context.Context, b *blockchain.StorageNode,
	connID string, timeOut time.Duration, wg *sync.WaitGroup,
)

Change status code to 204

type YoutubeDL added in v1.2.88

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

YoutubeDL wrap youtube-dl to download video from youtube

func CreateYoutubeDL added in v1.2.88

func CreateYoutubeDL(ctx context.Context, localPath string, feedURL string, downloadArgs []string, ffmpegArgs []string, delay int) (*YoutubeDL, error)

CreateYoutubeDL create a youtube-dl instance to download video file from youtube

  • localPath: output file path
  • feedURL: youtube video url
  • downloadArgs: youtube-dl download arguments
  • ffmpegArgs: ffmpeg arguments
  • delay: delay in seconds

func (*YoutubeDL) Close added in v1.2.88

func (r *YoutubeDL) Close() error

Close implements io.Closer

func (*YoutubeDL) GetClipsFile added in v1.2.88

func (r *YoutubeDL) GetClipsFile(clipsIndex int) string

GetClipsFile get clips file

func (*YoutubeDL) GetClipsFileName added in v1.2.88

func (r *YoutubeDL) GetClipsFileName(clipsIndex int) string

GetClipsFileName get clips file name

func (*YoutubeDL) GetFileContentType added in v1.2.88

func (r *YoutubeDL) GetFileContentType() (string, error)

GetFileContentType get MIME type

func (*YoutubeDL) Read added in v1.2.88

func (r *YoutubeDL) Read(p []byte) (int, error)

Read implements io.Raader

func (*YoutubeDL) Size added in v1.2.88

func (r *YoutubeDL) Size() int64

Size get current clips size

Jump to

Keyboard shortcuts

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