Documentation ¶
Overview ¶
Utility functions to support the functionality of the SDK.
Index ¶
- Constants
- Variables
- func Decrypt(key, text []byte) ([]byte, error)
- func DeleteCollaboratorRequest(baseUrl, allocationID, allocationTx, sig string, query *url.Values) (*http.Request, error)
- func Encrypt(key, text []byte) ([]byte, error)
- func GetActiveBlobbers(dirMask uint32, blobbers []*blockchain.StorageNode) []*blockchain.StorageNode
- func GetCollaboratorsRequest(baseUrl, allocationID, allocationTx, sig string, query *url.Values) (*http.Request, error)
- func GetErrorMessageCode(errorMsg string) (string, error)
- func GetFastHTTPClient() *fasthttp.Client
- func GetFastRateLimitValue(r *fasthttp.Response) (int, error)
- func GetFileContentType(ext string, out io.ReadSeeker) (string, error)
- func GetFullRemotePath(localPath, remotePath string) string
- func GetLogger() *logger.Logger
- func GetRateLimitValue(r *http.Response) (int, error)
- func GetRefsHash(r []byte) string
- func HttpDo(ctx context.Context, cncl context.CancelFunc, req *http.Request, ...) error
- func IsRemoteAbs(path string) bool
- func MajorError(errors []error) error
- func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]string, ...) ([]byte, error)
- func NewAllocationRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)
- func NewCalculateHashRequest(baseUrl, allocationID string, allocationTx string, paths []string) (*http.Request, error)
- func NewCollaboratorRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewCommitRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)
- func NewConnectionId() string
- func NewConnectionRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewCopyRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewCreateDirRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewDeleteRequest(baseUrl, allocationID, allocationTx, sig string, query *url.Values) (*http.Request, error)
- func NewDownloadRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)
- func NewFastDownloadRequest(baseUrl, allocationID, allocationTx string) (*fasthttp.Request, error)
- func NewFastUploadRequest(baseURL, allocationID string, allocationTx string, body []byte, method string) (*fasthttp.Request, error)
- func NewFileMetaRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewFileStatsRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewHTTPRequest(method string, url string, data []byte) (*http.Request, context.Context, context.CancelFunc, error)
- func NewListRequest(baseUrl, allocationID, allocationTx, path, pathHash, auth_token string, ...) (*http.Request, error)
- func NewMoveRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewObjectTreeRequest(baseUrl, allocationID string, allocationTx string, sig string, path string) (*http.Request, error)
- func NewRecentlyAddedRefsRequest(bUrl, allocID, allocTx, sig string, fromDate, offset int64, pageLimit int) (*http.Request, error)
- func NewRedeemRequest(baseUrl, allocationID, allocationTx string) (*http.Request, error)
- func NewReferencePathRequest(baseUrl, allocationID string, allocationTx string, sig string, paths []string) (*http.Request, error)
- func NewRefsRequest(...) (*http.Request, error)
- func NewRenameRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewRevokeShareRequest(baseUrl, allocationID, allocationTx, sig string, query *url.Values) (*http.Request, error)
- func NewRollbackRequest(baseUrl, allocationID string, allocationTx string, body io.Reader) (*http.Request, error)
- func NewShareRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader) (*http.Request, error)
- func NewUploadRequest(baseUrl, allocationID, allocationTx, sig string, body io.Reader, update bool) (*http.Request, error)
- func NewUploadRequestWithMethod(baseURL, allocationID, allocationTx, sig string, body io.Reader, method string) (*http.Request, error)
- func NewWriteMarkerLockRequest(baseURL, allocationID, allocationTx, sig, connID string) (*http.Request, error)
- func NewWriteMarkerUnLockRequest(baseURL, allocationID, allocationTx, sig, connID, requestTime string) (*http.Request, error)
- func NewWritemarkerRequest(baseUrl, allocationID, allocationTx, sig string) (*http.Request, error)
- func RemoteClean(path string) string
- func ScryptDecrypt(key, ciphertext []byte) ([]byte, error)
- func ScryptEncrypt(key, text []byte) ([]byte, error)
- func Transpose(matrix [][]allocationchange.AllocationChange) [][]allocationchange.AllocationChange
- type DownloadBuffer
- type DownloadBufferWithChan
- type DownloadBufferWithMask
- type FastClient
- type HttpClient
- type SCRestAPIHandler
- type Uint128
- func (x Uint128) Add(y Uint128) Uint128
- func (x Uint128) Add64(y uint64) Uint128
- func (x Uint128) And(v Uint128) Uint128
- func (x Uint128) And64(y uint64) Uint128
- func (x Uint128) CountOnes() int
- func (x Uint128) Equals(y Uint128) bool
- func (x Uint128) Equals64(y uint64) bool
- func (x Uint128) Lsh(y uint64) Uint128
- func (x Uint128) Not() Uint128
- func (x Uint128) Or(v Uint128) Uint128
- func (x Uint128) Sub(y Uint128) Uint128
- func (x Uint128) Sub64(y uint64) Uint128
- func (x Uint128) TrailingZeros() int
- func (x Uint128) Xor(v Uint128) Uint128
Constants ¶
const ( ALLOCATION_ENDPOINT = "/allocation" UPLOAD_ENDPOINT = "/v1/file/upload/" RENAME_ENDPOINT = "/v1/file/rename/" COPY_ENDPOINT = "/v1/file/copy/" MOVE_ENDPOINT = "/v1/file/move/" LIST_ENDPOINT = "/v1/file/list/" REFERENCE_ENDPOINT = "/v1/file/referencepath/" CONNECTION_ENDPOINT = "/v1/connection/details/" COMMIT_ENDPOINT = "/v1/connection/commit/" DOWNLOAD_ENDPOINT = "/v1/file/download/" LATEST_READ_MARKER = "/v1/readmarker/latest" FILE_META_ENDPOINT = "/v1/file/meta/" FILE_STATS_ENDPOINT = "/v1/file/stats/" OBJECT_TREE_ENDPOINT = "/v1/file/objecttree/" REFS_ENDPOINT = "/v1/file/refs/" RECENT_REFS_ENDPOINT = "/v1/file/refs/recent/" COLLABORATOR_ENDPOINT = "/v1/file/collaborator/" CALCULATE_HASH_ENDPOINT = "/v1/file/calculatehash/" SHARE_ENDPOINT = "/v1/marketplace/shareinfo/" DIR_ENDPOINT = "/v1/dir/" PLAYLIST_LATEST_ENDPOINT = "/v1/playlist/latest/" PLAYLIST_FILE_ENDPOINT = "/v1/playlist/file/" WM_LOCK_ENDPOINT = "/v1/writemarker/lock/" CREATE_CONNECTION_ENDPOINT = "/v1/connection/create/" LATEST_WRITE_MARKER_ENDPOINT = "/v1/file/latestwritemarker/" ROLLBACK_ENDPOINT = "/v1/connection/rollback/" REDEEM_ENDPOINT = "/v1/connection/redeem/" // CLIENT_SIGNATURE_HEADER represents http request header contains signature. CLIENT_SIGNATURE_HEADER = "X-App-Client-Signature" CLIENT_SIGNATURE_HEADER_V2 = "X-App-Client-Signature-V2" ALLOCATION_ID_HEADER = "ALLOCATION-ID" )
const EncryptedFolderName = "encrypted"
const MAX_RETRIES = 5
const SC_REST_API_URL = "v1/screst/"
const SLEEP_BETWEEN_RETRIES = 5
Variables ¶
var ( Client HttpClient FastHttpClient FastClient SignCache simplelru.LRUCache[string, string] )
var BufferPool bytebufferpool.Pool
var DefaultTransport = &http.Transport{ Proxy: envProxy.Proxy, DialContext: (&net.Dialer{ Timeout: 3 * time.Minute, KeepAlive: 45 * time.Second, DualStack: true, }).DialContext, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 45 * time.Second, ExpectContinueTimeout: 1 * time.Second, MaxIdleConnsPerHost: 25, }
Functions ¶
func GetActiveBlobbers ¶ added in v1.8.6
func GetActiveBlobbers(dirMask uint32, blobbers []*blockchain.StorageNode) []*blockchain.StorageNode
func GetCollaboratorsRequest ¶
func GetErrorMessageCode ¶ added in v1.8.16
Returns the error message code, message should be strictly of the format: ".... err: {"code" : <return_this>, ...}, ..."
func GetFastHTTPClient ¶ added in v1.15.9
func GetFastRateLimitValue ¶ added in v1.13.0
func GetFileContentType ¶
func GetFileContentType(ext string, out io.ReadSeeker) (string, error)
GetFileContentType returns the content type of the file based on reading the first 10KB of the file
- ext is the extension of the file, shouldn't be empty
- out is the file content
func GetFullRemotePath ¶
GetFullRemotePath returns the full remote path by combining the local path and remote path
- localPath is the local path of the file
- remotePath is the remote path of the file
func GetRefsHash ¶ added in v1.3.0
func IsRemoteAbs ¶
IsRemoteAbs returns true if the path is remote absolute path
- path is the path to check
func MajorError ¶ added in v1.8.16
func MakeSCRestAPICall ¶
func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]string, handler SCRestAPIHandler) ([]byte, error)
MakeSCRestAPICall makes a rest api call to the sharders.
- scAddress is the address of the smart contract
- relativePath is the relative path of the api
- params is the query parameters
- handler is the handler function to handle the response
func NewAllocationRequest ¶
func NewCalculateHashRequest ¶
func NewCollaboratorRequest ¶
func NewCommitRequest ¶
func NewConnectionId ¶
func NewConnectionId() string
NewConnectionId generate new connection id. Connection is used to track the upload/download progress and redeem the cost of the operation from the network. It's in the short uuid format. Check here for more on this format: https://pkg.go.dev/github.com/lithammer/shortuuid/v3@v3.0.7
func NewConnectionRequest ¶ added in v1.8.17
func NewCopyRequest ¶
func NewCreateDirRequest ¶
func NewDeleteRequest ¶
func NewDownloadRequest ¶
func NewFastDownloadRequest ¶ added in v1.13.0
func NewFastUploadRequest ¶ added in v1.13.0
func NewFileMetaRequest ¶
func NewFileStatsRequest ¶
func NewHTTPRequest ¶
func NewListRequest ¶
func NewMoveRequest ¶ added in v1.8.10
func NewObjectTreeRequest ¶
func NewRecentlyAddedRefsRequest ¶ added in v1.8.7
func NewRedeemRequest ¶ added in v1.8.17
func NewReferencePathRequest ¶
func NewRefsRequest ¶ added in v1.3.0
func NewRenameRequest ¶
func NewRevokeShareRequest ¶
func NewRollbackRequest ¶ added in v1.8.17
func NewShareRequest ¶
func NewUploadRequest ¶
func NewUploadRequestWithMethod ¶ added in v1.2.88
func NewUploadRequestWithMethod(baseURL, allocationID, allocationTx, sig string, body io.Reader, method string) (*http.Request, error)
NewUploadRequestWithMethod create a http request of upload
func NewWriteMarkerLockRequest ¶ added in v1.8.9
func NewWriteMarkerUnLockRequest ¶ added in v1.8.9
func NewWritemarkerRequest ¶ added in v1.8.17
func ScryptDecrypt ¶ added in v1.8.15
func ScryptEncrypt ¶ added in v1.8.15
func Transpose ¶ added in v1.8.17
func Transpose(matrix [][]allocationchange.AllocationChange) [][]allocationchange.AllocationChange
Returns transpose of 2-D slice Example: Given matrix [[a, b], [c, d], [e, f]] returns [[a, c, e], [b, d, f]]
Types ¶
type DownloadBuffer ¶ added in v1.12.1
type DownloadBufferWithChan ¶ added in v1.13.0
type DownloadBufferWithChan struct {
// contains filtered or unexported fields
}
func NewDownloadBufferWithChan ¶ added in v1.13.0
func NewDownloadBufferWithChan(size, numBlocks, effectiveBlockSize int) *DownloadBufferWithChan
func (*DownloadBufferWithChan) ClearBuffer ¶ added in v1.13.7
func (r *DownloadBufferWithChan) ClearBuffer()
func (*DownloadBufferWithChan) ReleaseChunk ¶ added in v1.13.0
func (r *DownloadBufferWithChan) ReleaseChunk(num int)
func (*DownloadBufferWithChan) RequestChunk ¶ added in v1.13.0
func (r *DownloadBufferWithChan) RequestChunk(ctx context.Context, num int) []byte
type DownloadBufferWithMask ¶ added in v1.13.0
type DownloadBufferWithMask struct {
// contains filtered or unexported fields
}
func NewDownloadBufferWithMask ¶ added in v1.13.0
func NewDownloadBufferWithMask(size, numBlocks, effectiveBlockSize int) *DownloadBufferWithMask
func (*DownloadBufferWithMask) ClearBuffer ¶ added in v1.13.7
func (r *DownloadBufferWithMask) ClearBuffer()
func (*DownloadBufferWithMask) ReleaseChunk ¶ added in v1.13.0
func (r *DownloadBufferWithMask) ReleaseChunk(num int)
func (*DownloadBufferWithMask) RequestChunk ¶ added in v1.13.0
func (r *DownloadBufferWithMask) RequestChunk(ctx context.Context, num int) []byte
func (*DownloadBufferWithMask) SetNumBlocks ¶ added in v1.13.14
func (r *DownloadBufferWithMask) SetNumBlocks(numBlocks int)
type FastClient ¶ added in v1.13.0
type SCRestAPIHandler ¶
SCRestAPIHandler is a function type to handle the response from the SC Rest API
`response` - the response from the SC Rest API `numSharders` - the number of sharders that responded `err` - the error if any
type Uint128 ¶
func NewUint128 ¶
func (Uint128) TrailingZeros ¶
TrailingZeros returns the number of trailing zero bits in x; the result is 128 for x == 0.