zbox

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertZcnTokenToETH

func ConvertZcnTokenToETH(token float64) (string, error)

ConvertZcnTokenToETH - converting Zcn tokens to Eth

func Decrypt

func Decrypt(key, text string) (string, error)

Decrypt - decrypting text with key

func Encrypt

func Encrypt(key, text string) (string, error)

Encrypt - encrypting text with key

func GEthToTokens

func GEthToTokens(tokens int64) string

func GetAllocations

func GetAllocations() (string, error)

GetAllocations return back list of allocations for the wallet Extracted from main method, bcz of class fields

func GetBlobbers

func GetBlobbers() (string, error)

GetBlobbers - get list of blobbers

func GetClientEncryptedPublicKey

func GetClientEncryptedPublicKey() (string, error)

GetClientEncryptedPublicKey - getting client encrypted pub key

func GetNetwork

func GetNetwork() (string, error)

GetNetwork - get current network

func GetNumber

func GetNumber(value string) int

func Init

func Init(chainConfigJson string) error

func RegisterToMiners

func RegisterToMiners(clientId, pubKey string, callback zcncore.WalletCallback) error

GetReadPoolInfo is to get information about the read pool for the allocation

func SetLogFile

func SetLogFile(logFile string, verbose bool)

SetLogFile - setting up log level for core libraries

func SetLogLevel

func SetLogLevel(logLevel int)

SetLogLevel set the log level. lvl - 0 disabled; higher number (upto 4) more verbosity

func Sign

func Sign(hash string) (string, error)

Sign - sign hash

func SuggestEthGasPrice

func SuggestEthGasPrice() (string, error)

SuggestEthGasPrice - return back suggested price for gas

func TokensToEth

func TokensToEth(tokens int64) string

func VerifySignature

func VerifySignature(signature string, msg string) (bool, error)

VerifySignature - verify message with signature

Types

type Allocation

type Allocation struct {
	ID           string `json:"id"`
	DataShards   int    `json:"data_shards"`
	ParityShards int    `json:"parity_shards"`
	Size         int64  `json:"size"`
	Expiration   int64  `json:"expiration_date"`
	Name         string `json:"name"`
	Stats        string `json:"stats"`
	// contains filtered or unexported fields
}

Allocation - structure for allocation object

func (*Allocation) CancelDownload

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

CancelDownload - cancel file download

func (*Allocation) CancelRepair

func (a *Allocation) CancelRepair() error

CancelRepair - cancel repair files from path

func (*Allocation) CancelUpload

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

CancelUpload - cancel file upload

func (*Allocation) CommitMetaTransaction

func (a *Allocation) CommitMetaTransaction(path, crudOperation, authTicket, lookupHash, fileMeta string, statusCb StatusCallbackMocked) error

CommitMetaTransaction - authTicket - Optional, Only when you do download using authTicket and lookUpHash. lookupHash - Same as above. fileMeta - Optional, Only when you do delete and have already fetched fileMeta before delete operation.

func (*Allocation) CopyObject

func (a *Allocation) CopyObject(path string, destPath string) error

CopyObject - copy object from path to dest

func (*Allocation) CreateDir

func (a *Allocation) CreateDir(dirName string) error

func (*Allocation) DeleteFile

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

DeleteFile - delete file from remote path

func (*Allocation) DownloadFile

func (a *Allocation) DownloadFile(remotePath, localPath string, statusCb StatusCallbackMocked) error

DownloadFile - start download file from remote path to localpath

func (*Allocation) DownloadFileByBlock

func (a *Allocation) DownloadFileByBlock(remotePath, localPath string, startBlock, endBlock int64, numBlocks int, statusCb StatusCallbackMocked) error

DownloadFileByBlock - start download file from remote path to localpath by blocks number

func (*Allocation) DownloadFromAuthTicket

func (a *Allocation) DownloadFromAuthTicket(localPath string, authTicket string, remoteLookupHash string, remoteFilename string, rxPay bool, status StatusCallbackMocked) error

DownloadFromAuthTicket - download file from Auth ticket

func (*Allocation) DownloadFromAuthTicketByBlocks

func (a *Allocation) DownloadFromAuthTicketByBlocks(localPath string, authTicket string, startBlock, endBlock int64, numBlocks int, remoteLookupHash string, remoteFilename string, rxPay bool, status StatusCallbackMocked) error

DownloadFromAuthTicketByBlocks - download file from Auth ticket by blocks number

func (*Allocation) DownloadThumbnail

func (a *Allocation) DownloadThumbnail(remotePath, localPath string, statusCb StatusCallbackMocked) error

DownloadThumbnail - start download file thumbnail from remote path to localpath

func (*Allocation) DownloadThumbnailFromAuthTicket

func (a *Allocation) DownloadThumbnailFromAuthTicket(localPath string, authTicket string, remoteLookupHash string, remoteFilename string, rxPay bool, status StatusCallbackMocked) error

DownloadThumbnailFromAuthTicket - downloadThumbnail from Auth ticket

func (*Allocation) EncryptAndUpdateFile

func (a *Allocation) EncryptAndUpdateFile(tmpPath, localPath, remotePath, fileAttrs string, statusCb StatusCallbackMocked) error

EncryptAndUpdateFile - update file from local path to remote path from encrypted folder

func (*Allocation) EncryptAndUpdateFileWithThumbnail

func (a *Allocation) EncryptAndUpdateFileWithThumbnail(tmpPath, localPath, remotePath, fileAttrs string, thumbnailpath string, statusCb StatusCallbackMocked) error

EncryptAndUpdateFileWithThumbnail - update file from local path to remote path from encrypted folder with Thumbnail

func (*Allocation) EncryptAndUploadFile

func (a *Allocation) EncryptAndUploadFile(tmpPath, localPath, remotePath, fileAttrs string, statusCb StatusCallbackMocked) error

EncryptAndUploadFile - start upload encrypted file

func (*Allocation) EncryptAndUploadFileWithThumbnail

func (a *Allocation) EncryptAndUploadFileWithThumbnail(tmpPath, localPath, remotePath, fileAttrs string, thumbnailpath string, statusCb StatusCallbackMocked) error

EncryptAndUploadFileWithThumbnail - start upload encrypted file with thumbnail

func (*Allocation) GetAllocationStats

func (a *Allocation) GetAllocationStats() (string, error)

GetStatistics - get allocation stats

func (*Allocation) GetAuthToken

func (a *Allocation) GetAuthToken(path string, filename string, referenceType string, refereeClientID string, refereeEncryptionPublicKey string, expiration int64) (string, error)

GetAuthToken - get auth token from refereeClientID

func (*Allocation) GetBlobberStats

func (a *Allocation) GetBlobberStats() (string, error)

GetBlobberStats - get blobbers stats

func (*Allocation) GetCurrentManifest

func (a *Allocation) GetCurrentManifest() string

func (*Allocation) GetDiff

func (a *Allocation) GetDiff(lastSyncCachePath string, localRootPath string, localFileFilters string, remoteExcludePaths string) (string, error)

GetDiff - cancel file diff

func (*Allocation) GetFileMeta

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

GetFileMeta - getting file meta details from file path

func (*Allocation) GetFileMetaFromAuthTicket

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

GetFileMetaFromAuthTicket - getting file meta details from file path and auth ticket

func (*Allocation) GetFileStats

func (a *Allocation) GetFileStats(path string) (string, error)

GetFileStats - get file stats from path

func (*Allocation) GetFirstSegment

func (a *Allocation) GetFirstSegment(localPath, remotePath, tmpPath string, delay, maxSegments int) (string, error)

GetFirstSegment - getting the amount of segments in maxSegments for very first playback

func (*Allocation) GetMaxStorageCost

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

GetMaxStorageCost - getting back max cost for allocation

func (*Allocation) GetMaxStorageCostWithBlobbers

func (a *Allocation) GetMaxStorageCostWithBlobbers(size int64, blobbersJson string) (string, error)

GetMaxStorageCostWithBlobbers - getting cost for listed blobbers

func (*Allocation) GetMinStorageCost

func (a *Allocation) GetMinStorageCost(size int64) (string, error)

GetMinStorageCost - getting back min cost for allocation

func (*Allocation) GetMinWriteRead

func (a *Allocation) GetMinWriteRead() (string, error)

GetMinWriteRead - getting back cost for allocation

func (*Allocation) GetShareAuthToken

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

GetShareAuthToken - get auth ticket from refereeClientID

func (*Allocation) ListDir

func (a *Allocation) ListDir(path string) (string, error)

ListDir - listing files from path

func (*Allocation) ListDirFromAuthTicket

func (a *Allocation) ListDirFromAuthTicket(authTicket string, lookupHash string) (string, error)

ListDirFromAuthTicket - listing files from path with auth ticket

func (*Allocation) MoveObject

func (a *Allocation) MoveObject(path string, destPath string) error

MoveObject - move object from path to dest

func (*Allocation) PlayStreaming

func (a *Allocation) PlayStreaming(localPath, remotePath, authTicket, lookupHash, initSegment string, delay int, statusCb StatusCallbackWrapped) error

GetMinStorageCost - getting back min cost for allocation

func (*Allocation) RenameObject

func (a *Allocation) RenameObject(remotePath string, destName string) error

RenameObject - rename or move file

func (*Allocation) RepairFile

func (a *Allocation) RepairFile(localPath, remotePath string, statusCb StatusCallbackMocked) error

RepairFile - repairing file if it's exist in remote path

func (*Allocation) SaveRemoteSnapshot

func (a *Allocation) SaveRemoteSnapshot(pathToSave string, remoteExcludePaths string) error

SaveRemoteSnapshot - saving remote snapshot

func (*Allocation) StartRepair

func (a *Allocation) StartRepair(localRootPath, pathToRepair string, statusCb StatusCallbackMocked) error

StartRepair - start repair files from path

func (*Allocation) StopStreaming

func (a *Allocation) StopStreaming() error

func (*Allocation) UpdateFile

func (a *Allocation) UpdateFile(workDir, localPath, remotePath, fileAttrs string, statusCb StatusCallbackMocked) error

UpdateFile - update file from local path to remote path

func (*Allocation) UpdateFileWithThumbnail

func (a *Allocation) UpdateFileWithThumbnail(workDir, localPath, remotePath, fileAttrs string, thumbnailpath string, statusCb StatusCallbackMocked) error

UpdateFileWithThumbnail - update file from local path to remote path with Thumbnail

func (*Allocation) UploadFile

func (a *Allocation) UploadFile(workdir, localPath, remotePath, fileAttrs string, statusCb StatusCallbackMocked) error

UploadFile - start upload file thumbnail from localpath to remote path

func (*Allocation) UploadFileWithThumbnail

func (a *Allocation) UploadFileWithThumbnail(tmpPath, localPath, remotePath, fileAttrs string, thumbnailpath string, statusCb StatusCallbackMocked) error

UploadFileWithThumbnail - start upload file with thumbnail

type AuthTicket

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

AuthTicket - auth ticket structure

func InitAuthTicket

func InitAuthTicket(authTicket string) *AuthTicket

InitAuthTicket - init auth ticket from ID

func (*AuthTicket) GetFilename

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

GetFilename - getting file name

func (*AuthTicket) IsDir

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

IsDir - checking if it's dir

type ChainConfig

type ChainConfig struct {
	ChainID           string   `json:"chain_id,omitempty"`
	PreferredBlobbers []string `json:"preferred_blobbers"`
	BlockWorker       string   `json:"block_worker"`
	SignatureScheme   string   `json:"signature_scheme"`
}

ChainConfig - blockchain config

type GetBalanceCallback

type GetBalanceCallback interface {
	OnBalanceAvailable(status int, value int64, info string)
}

GetBalanceCallback needs to be implemented by the caller of GetBalance() to get the status

type M3u8Downloader

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

M3u8Downloader download files from blobber's dir, and build them into a local m3u8 playlist

type M3u8Writer

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

M3u8Writer m3u8 writer

type MediaItem

type MediaItem struct {
	Name string
	Path string
}

MediaItem is .ts file

type MediaPlaylist

type MediaPlaylist struct {
	Writer M3u8Writer

	Wait []string

	Seq int
	// contains filtered or unexported fields
}

MediaPlaylist m3u8 encoder and decoder

func NewMediaPlaylist

func NewMediaPlaylist(delay int, writer M3u8Writer) *MediaPlaylist

NewMediaPlaylist create media playlist(.m3u8)

func (*MediaPlaylist) Append

func (m *MediaPlaylist) Append(item string)

Append append new item

func (*MediaPlaylist) Encode

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

Encode encode m3u8

func (*MediaPlaylist) Play

func (m *MediaPlaylist) Play()

Play start to push item into playlist

func (*MediaPlaylist) String

func (m *MediaPlaylist) String() string

String implement Stringer

type MinMaxCost

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

MinMaxCost - keeps cost for allocation update/creation

type StatusBarMocked

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

func (*StatusBarMocked) CommitMetaCompleted

func (s *StatusBarMocked) CommitMetaCompleted(request, response string, txn *transaction.Transaction, err error)

func (*StatusBarMocked) Completed

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

func (*StatusBarMocked) Error

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

func (*StatusBarMocked) InProgress

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

func (*StatusBarMocked) RepairCompleted

func (s *StatusBarMocked) RepairCompleted(filesRepaired int)

func (*StatusBarMocked) Started

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

type StatusCallbackMocked

type StatusCallbackMocked 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)
	CommitMetaCompleted(request, response string, err error)
	RepairCompleted(filesRepaired int)
}

type StatusCallbackWrapped

type StatusCallbackWrapped struct {
	Callback StatusCallbackMocked
}

func (*StatusCallbackWrapped) CommitMetaCompleted

func (c *StatusCallbackWrapped) CommitMetaCompleted(request, response string, txn *transaction.Transaction, err error)

func (*StatusCallbackWrapped) Completed

func (c *StatusCallbackWrapped) Completed(allocationId, filePath string, filename string, mimetype string, size int, op int)

func (*StatusCallbackWrapped) Error

func (c *StatusCallbackWrapped) Error(allocationID string, filePath string, op int, err error)

func (*StatusCallbackWrapped) InProgress

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

func (*StatusCallbackWrapped) RepairCompleted

func (c *StatusCallbackWrapped) RepairCompleted(filesRepaired int)

func (*StatusCallbackWrapped) Started

func (c *StatusCallbackWrapped) Started(allocationId, filePath string, op int, totalBytes int)

type StorageSDK

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

StorageSDK - storage SDK config

func InitStorageSDK

func InitStorageSDK(clientjson string, configjson string) (*StorageSDK, error)

InitStorageSDK - init storage sdk from config

func (*StorageSDK) CancelAllocation

func (s *StorageSDK) CancelAllocation(allocationID string) (string, error)

CancelAllocation - cancel allocation by ID

func (*StorageSDK) CreateAllocation

func (s *StorageSDK) CreateAllocation(name string, datashards, parityshards int, size, expiration, lock int64) (*Allocation, error)

CreateAllocation - creating new allocation

func (*StorageSDK) CreateAllocationWithBlobbers

func (s *StorageSDK) CreateAllocationWithBlobbers(name string, datashards, parityshards int, size, expiration, lock int64, blobbersRaw string) (*Allocation, error)

CreateAllocationWithBlobbers - creating new allocation with list of blobbers

func (*StorageSDK) CreateReadPool

func (s *StorageSDK) CreateReadPool() error

CreateReadPool is to create read pool for the wallet

func (*StorageSDK) FinalizeAllocation

func (s *StorageSDK) FinalizeAllocation(allocationID string) (string, error)

FinalizeAllocation - finalize allocation

func (*StorageSDK) GetAllocation

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

GetAllocation - get allocation from ID

func (*StorageSDK) GetAllocationFromAuthTicket

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

GetAllocationFromAuthTicket - get allocation from Auth ticket

func (*StorageSDK) GetAllocationStats

func (s *StorageSDK) GetAllocationStats(allocationID string) (string, error)

GetAllocationStats - get allocation stats by allocation ID

func (*StorageSDK) GetAllocations

func (s *StorageSDK) GetAllocations() (string, error)

GetAllocations - get list of allocations

func (*StorageSDK) GetBlobbersList

func (s *StorageSDK) GetBlobbersList() (string, error)

GetBlobbersList get list of blobbers in string

func (*StorageSDK) GetReadPoolInfo

func (s *StorageSDK) GetReadPoolInfo(allocID string) (string, error)

GetReadPoolInfo is to get information about the read pool for the allocation

func (*StorageSDK) GetVersion

func (s *StorageSDK) GetVersion() string

GetVersion getting current version for gomobile lib

func (*StorageSDK) GetWritePoolInfo

func (s *StorageSDK) GetWritePoolInfo(allocID string) (string, error)

GetWritePoolInfo is to get information about the write pool for the allocation

func (*StorageSDK) ReadPoolLock

func (s *StorageSDK) ReadPoolLock(durInSeconds int64, tokens, fee float64, allocID, blobberID string) error

ReadPoolLock is to lock tokens into the read pool

func (*StorageSDK) ReadPoolUnlock

func (s *StorageSDK) ReadPoolUnlock(poolID string, fee float64) error

ReadPoolUnlock is to unlock tokens from read pool

func (*StorageSDK) UpdateAllocation

func (s *StorageSDK) UpdateAllocation(name string, size, expiry int64, allocationID string, lock int64) (hash string, err error)

UpdateAllocation with new expiry and size

func (*StorageSDK) WritePoolLock

func (s *StorageSDK) WritePoolLock(durInSeconds int64, tokens, fee float64, allocID, blobberID string) error

WritePoolLock is to lock tokens into the write pool

func (*StorageSDK) WritePoolUnlock

func (s *StorageSDK) WritePoolUnlock(poolID string, fee float64) error

WritePoolUnlock is to unlock tokens from write pool

type StreamingImpl

type StreamingImpl interface {
	GetFirstSegment(localPath, remotePath, tmpPath string, delay, maxSegments int) (string, error)
	PlayStreaming(localPath, remotePath, authTicket, lookupHash, initSegment string, delay int, statusCb StatusCallbackWrapped) error
	Stop() error
	GetCurrentManifest() string
}

StreamingService - implementation of streaming service

func CreateStreamingService

func CreateStreamingService(allocation *Allocation) StreamingImpl

CreateStreamingService - creating streaming service instance

type StreamingService

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

StreamingService - holder for streaming service

func (*StreamingService) GetCurrentManifest

func (s *StreamingService) GetCurrentManifest() string

func (*StreamingService) GetFirstSegment

func (s *StreamingService) GetFirstSegment(localPath, remotePath, tmpPath string, delay, maxSegments int) (string, error)

GetFirstSegment - getting the amount of segments in maxSegments for very first playback

func (*StreamingService) PlayStreaming

func (s *StreamingService) PlayStreaming(localPath, remotePath, authTicket, lookupHash, initSegment string, delay int, statusCb StatusCallbackWrapped) error

PlayStreaming - start streaming playback

func (*StreamingService) Stop

func (s *StreamingService) Stop() error

TODO

type WalletCallback

type WalletCallback interface {
	OnWalletCreateComplete(status int, wallet string, err string)
}

WalletCallback needs to be implmented for wallet creation.

Jump to

Keyboard shortcuts

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