client

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceOfAddress

type BalanceOfAddress struct {
	Balance    string
	BalanceHex string
	Nounce     string
	NextNounce string
}

BalanceOfAddress represents the balance response of an address.

type Client

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

Client represents the client data.

func New

func New(urlEndpoint string, httpClient HTTPClient) (*Client, error)

New creates a new client.

func (*Client) Authorized added in v1.1.16

func (cli *Client) Authorized(ctx context.Context, token string) (bool, error)

Authorized checks if an access token is authorized.

func (*Client) Balance

func (cli *Client) Balance(ctx context.Context, address string) (BalanceOfAddress, error)

Balance returns the balance and nounces of an address.

func (*Client) ChannelFilesFromEntryOrFolder

func (cli *Client) ChannelFilesFromEntryOrFolder(ctx context.Context, nodeHash string) (rpc.FilesFromEntryOrFolderResponse, error)

ChannelFilesFromEntryOrFolder gets a list of files recursively under an entry or a directory.

func (*Client) CheckDataQueryResponse

func (cli *Client) CheckDataQueryResponse(ctx context.Context, dataQueryRequestHash string) (rpc.CheckDataQueryResponse, error)

CheckDataQueryResponse checks for a data query response.

func (*Client) CreateChannelNodeItemsTxDataPayload added in v1.1.7

func (cli *Client) CreateChannelNodeItemsTxDataPayload(ctx context.Context, nodes []rpc.NodeItemJSON) (string, string, error)

CreateChannelNodeItemsDataPayload creates the transaction data payload given the channel node items list.

func (*Client) CreateContractsFromDataQueryResponses

func (cli *Client) CreateContractsFromDataQueryResponses(ctx context.Context, dataQueryRequestHash string) ([]string, error)

CreateContractsFromDataQueryResponses creates contract based on the data query responses on this node.

func (*Client) CreateTransactionsWithDataPayloadFromContractHashes

func (cli *Client) CreateTransactionsWithDataPayloadFromContractHashes(ctx context.Context, contractHashes []string, accessToken, currentAddressNounce, transactionFeesToBeUsed string) ([]string, string, error)

CreateTransactionsWithDataPayloadFromContractHashes given a list of contract hashes it creates the transactions and its data payloads and returns them in a raw json format.

func (*Client) DownloadFile

func (cli *Client) DownloadFile(ctx context.Context, contractHash, fileHash string, reDownload bool) (string, error)

DownloadFile requests a file download from file hoster given the file segments start and end.

func (*Client) DownloadFileProgress

func (cli *Client) DownloadFileProgress(ctx context.Context, contractHash, fileHash string) (rpc.DownloadFileProgressResponse, error)

DownloadFileProgress reports the file download progress.

func (*Client) GetBlockByHash

func (cli *Client) GetBlockByHash(ctx context.Context, blockHash string) (rpc.JSONBlock, error)

GetBlockByHash get a block by hash.

func (*Client) GetBlockByNumber

func (cli *Client) GetBlockByNumber(ctx context.Context, blockNumber uint64) (rpc.JSONBlock, error)

GetBlockByNumber get a block by number.

func (*Client) GetBlockPool

func (cli *Client) GetBlockPool(ctx context.Context) (rpc.PoolResponse, error)

GetBlockPool gets the block pool of the node.

func (*Client) GetChannelNodeItem

func (cli *Client) GetChannelNodeItem(ctx context.Context, nodeHash string) (rpc.GetNodeItemResponse, error)

GetChannelNodeItem gets channel node item.

func (*Client) GetDownloadContract

func (cli *Client) GetDownloadContract(ctx context.Context, contractHash string) (rpc.GetDownloadContractResponse, error)

GetDownloadContract gets a download contract

func (*Client) GetHostInfo

func (cli *Client) GetHostInfo(ctx context.Context) (rpc.HostInfoResponse, error)

GetHostInfo gets the node's info.

func (*Client) GetNodeStats

func (cli *Client) GetNodeStats(ctx context.Context) (rpc.StatsResponse, error)

GetNodeStats gets the node's stats.

func (*Client) GetStorageAccessToken

func (cli *Client) GetStorageAccessToken(ctx context.Context, storageAdminToken string) (string, error)

GetStorageAccessToken gets a user access token based on the admin access token to be used for uploading data.

func (*Client) GetTransactionByAddress

func (cli *Client) GetTransactionByAddress(ctx context.Context, address string, currentPage, pageSize int) (rpc.TransactionsResponse, error)

GetTransactionByAddress given transactions of an address.

func (*Client) GetTransactionByHash

func (cli *Client) GetTransactionByHash(ctx context.Context, transactionHash string) (rpc.TransactionsResponse, error)

GetTransactionByHash given transactions hash returns the transaction data and block number.

func (*Client) ListAddresses added in v1.1.6

func (cli *Client) ListAddresses(ctx context.Context) ([]string, error)

ListAddresses lists the available addresses

func (*Client) ListChannels

func (cli *Client) ListChannels(ctx context.Context, currentPage, pageSize int, order string) (rpc.ListResponse, error)

ListChannels gets the list of channels.

func (*Client) LockAddress

func (cli *Client) LockAddress(ctx context.Context, address, token string) (bool, error)

LockAddress removes the unlocked address and jwt token to forbid access.

func (*Client) OverrideHTTPHeaders

func (cli *Client) OverrideHTTPHeaders(headers map[string]string)

OverrideHTTPHeaders adds headers to all requests.

func (*Client) PauseFileDownload added in v1.1.9

func (cli *Client) PauseFileDownload(ctx context.Context, contractHash, fileHash string) error

PauseFileDownload pauses a file download.

func (*Client) RebroadcastDataQueryRequest added in v1.1.16

func (cli *Client) RebroadcastDataQueryRequest(ctx context.Context, dataQueryRequestHash string) error

RebroadcastDataQueryRequest rebroadcasts a data query request.

func (*Client) RequestDataQueryResponseFromVerifiers

func (cli *Client) RequestDataQueryResponseFromVerifiers(ctx context.Context, dataQueryRequestHash string) (rpc.CheckDataQueryResponse, error)

RequestDataQueryResponseFromVerifiers requests data query responses from verifiers.

func (*Client) RequestEncryptionDataFromVerifierAndDecrypt

func (cli *Client) RequestEncryptionDataFromVerifierAndDecrypt(ctx context.Context, contractHash string, fileHashes, fileMerkleRootHashes, restoredFilePaths []string) ([]string, error)

RequestEncryptionDataFromVerifierAndDecrypt requests decryption data from verifier and decrypts the files to the provides output paths.

func (*Client) SearchChannels

func (cli *Client) SearchChannels(ctx context.Context, query string, searchType search.Type, size, currentPage int, fieldScope string) (rpc.SearchResponse, error)

SearchChannels search channel items.

func (*Client) SendContractToFileHosterAndVerifier

func (cli *Client) SendContractToFileHosterAndVerifier(ctx context.Context, contractHash string) (bool, error)

SendContractToFileHosterAndVerifier sends a contract to verifier and file hoster.

func (*Client) SendDataQueryRequest

func (cli *Client) SendDataQueryRequest(ctx context.Context, fileHashes []string) (string, error)

SendDataQueryRequest sends a data query request.

func (*Client) SendFileMerkleTreeNodesToVerifier

func (cli *Client) SendFileMerkleTreeNodesToVerifier(ctx context.Context, contractHash, fileHash string) (bool, error)

SendFileMerkleTreeNodesToVerifier send the files merkle tree nodes to verifier.

func (*Client) SendRawTransaction

func (cli *Client) SendRawTransaction(ctx context.Context, jsonEncodedTransactionBytes string) (rpc.TransactionResponse, error)

SendRawTransaction sends a raw transaction.

func (*Client) SendTransaction

func (cli *Client) SendTransaction(ctx context.Context, token string, tx SendTransaction) (rpc.TransactionResponse, error)

SendTransaction sends a transaction. this method requires the address to be unlocked and a token supplied

func (*Client) TransactionPool

func (cli *Client) TransactionPool(ctx context.Context) (rpc.MemPoolResponse, error)

TransactionPool returns the transaction in the tx pool

func (*Client) UnlockAddress

func (cli *Client) UnlockAddress(ctx context.Context, address, passphrase string) (string, error)

UnlockAddress unlocks an address or a node identity key.

func (*Client) UploadFile

func (cli *Client) UploadFile(ctx context.Context, filePath, nodeHash, storageToken string) (FileUploadResponse, error)

UploadFile uploads a file given the path and storage access token.

type FileUploadResponse

type FileUploadResponse struct {
	Error          string `json:"error"`
	FileName       string `json:"file_name"`
	FileHash       string `json:"file_hash"`
	MerkleRootHash string `json:"merkle_root_hash"`
	Size           int    `json:"size"`
}

FileUploadResponse represents the uploaded file metadata.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient defines the functionality of an HTTP client.

type JSONRPCRequest

type JSONRPCRequest struct {
	JSONRPC string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	ID      uint64        `json:"id"`
}

JSONRPCRequest is the jsonrpc2.0 request.

type JSONRPCResponse

type JSONRPCResponse struct {
	Result interface{} `json:"result"`
	Error  string      `json:"error"`
	ID     uint64      `json:"id"`
}

JSONRPCResponse is the jsonrpc2.0 response.

type SendTransaction

type SendTransaction struct {
	Nounce          string
	Data            string
	From            string
	To              string
	Value           string
	TransactionFees string
}

SendTransaction represents a tx to be sent to the network.

Jump to

Keyboard shortcuts

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