rpc

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: 39 Imported by: 0

Documentation

Index

Constants

View Source
const AddressServiceNamespace = "address"

AddressServiceNamespace is the namespace for address service rpc.

View Source
const BlockServiceNamespace = "block"

BlockServiceNamespace is the namespace for block service rpc.

View Source
const ChannelServiceNamespace = "channel"

ChannelServiceNamespace is the namespace for channel service rpc.

View Source
const DataTransferServiceNamespace = "data_transfer"

DataTransferServiceNamespace is the namespace for data transfer service rpc.

View Source
const FilefilegoServiceNamespace = "filefilego"

FilefilegoServiceNamespace is the namespace for filefilego service rpc.

View Source
const MediaCacheDirectory = "cache"

MediaCacheDirectory is the name of the cache directory

View Source
const StorageServiceNamespace = "storage"

StorageServiceNamespace is the namespace for storage service rpc.

View Source
const TransactionServiceNamespace = "transaction"

TransactionServiceNamespace is the namespace for transaction service rpc.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressAPI

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

AddressAPI represents address service

func NewAddressAPI

func NewAddressAPI(keystore keystore.KeyLockUnlockLister, bchain blockchain.Interface) (*AddressAPI, error)

NewAddressAPI creates a new address API to be served using JSONRPC.

func (*AddressAPI) Authorized added in v1.1.16

func (api *AddressAPI) Authorized(_ *http.Request, args *AuthorizedArgs, response *AuthorizedResponse) error

Authorized checks if an access token is currently available.

func (*AddressAPI) Balance

func (api *AddressAPI) Balance(_ *http.Request, args *BalanceOfAddressArgs, response *BalanceOfAddressResponse) error

Balance of an address.

func (*AddressAPI) List added in v1.1.6

func (api *AddressAPI) List(_ *http.Request, _ *EmptyArgs, response *ListAddressesResponse) error

List the addresses of the node.

func (*AddressAPI) Lock

func (api *AddressAPI) Lock(_ *http.Request, args *LockAddressArgs, response *LockAddressResponse) error

Lock a key given an access token and the address.

func (*AddressAPI) Unlock

func (api *AddressAPI) Unlock(_ *http.Request, args *UnlockAddressArgs, response *UnlockAddressResponse) error

Unlock a key given an address and a passphrase.

type AuthorizedArgs added in v1.1.16

type AuthorizedArgs struct {
	Token string `json:"token"`
}

AuthorizedArgs arguments required for checking authorized token.

type AuthorizedResponse added in v1.1.16

type AuthorizedResponse struct {
	Authorized bool `json:"authorized"`
}

AuthorizedResponse is a result of the authorization request.

type BalanceOfAddressArgs

type BalanceOfAddressArgs struct {
	Address string `json:"address"`
}

BalanceOfAddressArgs arguments required for balance of an address.

type BalanceOfAddressResponse

type BalanceOfAddressResponse struct {
	Balance    string `json:"balance"`
	BalanceHex string `json:"balance_hex"`
	Nounce     string `json:"nounce"`
	NextNounce string `json:"next_nounce"`
}

BalanceOfAddressResponse represents the balance response of an address.

type BlockAPI

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

BlockAPI represents the block rpc service.

func NewBlockAPI

func NewBlockAPI(bchain blockchain.Interface) (*BlockAPI, error)

NewBlockAPI creates a new block API to be served using JSONRPC.

func (*BlockAPI) GetByHash

func (api *BlockAPI) GetByHash(_ *http.Request, args *GetByHashArgs, response *JSONBlock) error

GetByHash gets a block by hash.

func (*BlockAPI) GetByNumber

func (api *BlockAPI) GetByNumber(_ *http.Request, args *GetByNumberArgs, response *JSONBlock) error

GetByNumber gets a block by number.

func (*BlockAPI) Pool

func (api *BlockAPI) Pool(r *http.Request, args *EmptyArgs, response *PoolResponse) error

Pool gets the block pool hashes. nolint:revive

type Blockchain

type Blockchain interface {
	PutMemPool(tx transaction.Transaction) error
	GetTransactionsFromPool() []transaction.Transaction
	GetAddressTransactions(address []byte, currentPage, limit int) ([]transaction.Transaction, []uint64, []int64, error)
	GetTransactionByHash(hash []byte) ([]transaction.Transaction, []uint64, error)
}

Blockchain defines the blockchain functionality needed for this rpc service,

type ByAddressArgs

type ByAddressArgs struct {
	Address     string `json:"address"`
	CurrentPage int    `json:"current_page"`
	PageSize    int    `json:"page_size"`
}

ByAddressArgs get transactions by address arguments.

type CancelFileDownloadsByContractHashArgs added in v1.1.25

type CancelFileDownloadsByContractHashArgs struct {
	ContractHash string `json:"contract_hash"`
}

CancelFileDownloadsByContractHashArgs represent args.

type CancelFileDownloadsByContractHashResponse added in v1.1.25

type CancelFileDownloadsByContractHashResponse struct {
	Success bool `json:"success"`
}

CancelFileDownloadsByContractHashResponse represent response.

type CancelUploadArgs added in v1.1.26

type CancelUploadArgs struct {
	Files []cancelPayload `json:"files"`
}

CancelUploadArgs args for canceling a file upload.

type CancelUploadResponse added in v1.1.26

type CancelUploadResponse struct {
	Success bool `json:"success"`
}

CancelUploadResponse is the response of a canceled upload.

type ChannelAPI

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

ChannelAPI represents the channel rpc service.

func NewChannelAPI

func NewChannelAPI(bchain blockchain.Interface, search search.IndexSearcher) (*ChannelAPI, error)

NewChannelAPI creates a new channel API to be served using JSONRPC.

func (*ChannelAPI) CreateNodeItemsTxDataPayload added in v1.1.7

func (api *ChannelAPI) CreateNodeItemsTxDataPayload(_ *http.Request, args *CreateNodeItemsTxDataPayloadArgs, response *CreateNodeItemsTxDataPayloadResponse) error

CreateNodeItemsTxDataPayload a channel node items that returns the transaction data payload, which in turn can be used in a transaction data payload. if IsUpdate is true, we calculate the fees and create an update envelope payload.

func (*ChannelAPI) FilesFromEntryOrFolder

func (api *ChannelAPI) FilesFromEntryOrFolder(_ *http.Request, args *FilesFromEntryOrFolderArgs, response *FilesFromEntryOrFolderResponse) error

FilesFromEntryOrFolder all the files of a node which is a dir or an entry recursvely.

func (*ChannelAPI) GetNodeItem

func (api *ChannelAPI) GetNodeItem(_ *http.Request, args *GetNodeItemArgs, response *GetNodeItemResponse) error

GetNodeItem gets a node item.

func (*ChannelAPI) List

func (api *ChannelAPI) List(_ *http.Request, args *ListArgs, response *ListResponse) error

List returns a list of channels.

func (*ChannelAPI) Search

func (api *ChannelAPI) Search(r *http.Request, args *SearchArgs, response *SearchResponse) error

Search search in nodes.

type CheckDataQueryResponse

type CheckDataQueryResponse struct {
	Responses []DataQueryResponseJSON `json:"responses"`
}

CheckDataQueryResponse is a data query response payload.

type CheckDataQueryResponseArgs

type CheckDataQueryResponseArgs struct {
	DataQueryRequestHash string `json:"data_query_request_hash"`
}

CheckDataQueryResponseArgs is a data query response arg.

type CreateContractsFromDataQueryResponsesArgs

type CreateContractsFromDataQueryResponsesArgs struct {
	DataQueryRequestHash      string `json:"data_query_request_hash"`
	AllowResponseOnlyFromPeer string `json:"allow_response_only_from_peer"`
}

CreateContractsFromDataQueryResponseHashArgs represents args. AllowResponseOnlyFromPeer contains a peerID which will filter the data query responses other than the given peer id.

type CreateContractsFromDataQueryResponsesResponse

type CreateContractsFromDataQueryResponsesResponse struct {
	ContractHashes []string `json:"contract_hashes"`
}

CreateContractsFromDataQueryResponsesResponse represents the response.

type CreateNodeItemsTxDataPayloadArgs added in v1.1.7

type CreateNodeItemsTxDataPayloadArgs struct {
	Nodes    []NodeItemJSON `json:"nodes"`
	IsUpdate bool           `json:"is_update"`
}

CreateNodeItemsTxDataPayloadArgs is a create channel node item request payload.

type CreateNodeItemsTxDataPayloadResponse added in v1.1.7

type CreateNodeItemsTxDataPayloadResponse struct {
	TransactionDataPayloadHex string `json:"transaction_data_payload_hex"`
	TotalFeesRequired         string `json:"total_fees_required"`
}

CreateNodeItemsTxDataPayloadResponse is a response which contains the transaction data payload for creating the channel node items. It contains the required fees for creating the provided node items based on their type.

type CreateTransactionDataPayloadFromContractHashesArgs

type CreateTransactionDataPayloadFromContractHashesArgs struct {
	AccessToken             string   `json:"access_token"`
	ContractHashes          []string `json:"contract_hashes"`
	CurrentNounce           string   `json:"current_nounce"`
	TransactionFeesToBeUsed string   `json:"transaction_fees_to_be_used"`
}

CreateTransactionDataPayloadFromContractHashesArgs represent the function args.

type CreateTransactionDataPayloadFromContractHashesResponse

type CreateTransactionDataPayloadFromContractHashesResponse struct {
	TransactionDataBytesHex  []string `json:"transaction_data_bytes_hex"`
	TotalFeesForTransactions string   `json:"total_fees_for_transaction"`
}

CreateTransactionDataPayloadFromContractHashesResponse represent the function response.

type DataQueryResponseJSON

type DataQueryResponseJSON struct {
	FromPeerAddr          string   `json:"from_peer_addr"`
	FeesPerByte           string   `json:"fees_per_byte"`
	HashDataQueryRequest  string   `json:"hash_data_query_request"`
	PublicKey             string   `json:"public_key"`
	Signature             string   `json:"signature"`
	FileHashes            []string `json:"file_hashes"`
	FileHashesSizes       []uint64 `json:"file_hashes_sizes"`
	UnavailableFileHashes []string `json:"unavailable_file_hashes"`
	Timestamp             int64    `json:"timestamp"`
	FileMerkleRootHashes  []string `json:"file_merkle_root_hashes"`
	FileNames             []string `json:"file_names"`
	FileFeesPerByte       []string `json:"file_fees_per_byte"`
}

DataQueryResponseJSON represents a json payload which represents a DataQueryResponse.

type DataTransferAPI

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

DataTransferAPI represents the data transfer rpc service which includes data query and verification protocols.

func NewDataTransferAPI

func NewDataTransferAPI(host host.Host, dataQueryProtocol dataquery.Interface, dataVerificationProtocol dataverification.Interface, publisherNodeFinder PublisherNodesFinder, contractStore contract.Interface, keystore keystore.KeyAuthorizer, dataDirectory string) (*DataTransferAPI, error)

NewDataTransferAPI creates a new data transfer API to be served using JSONRPC.

func (*DataTransferAPI) CancelFileDownloadsByContractHash added in v1.1.25

func (api *DataTransferAPI) CancelFileDownloadsByContractHash(_ *http.Request, args *CancelFileDownloadsByContractHashArgs, response *CancelFileDownloadsByContractHashResponse) error

CancelFileDownloadsByContractHash cancels file download by contract.

func (*DataTransferAPI) CheckDataQueryResponse

func (api *DataTransferAPI) CheckDataQueryResponse(_ *http.Request, args *CheckDataQueryResponseArgs, response *CheckDataQueryResponse) error

CheckDataQueryResponse returns a list of data query responses.

func (*DataTransferAPI) CreateContractsFromDataQueryResponses

func (api *DataTransferAPI) CreateContractsFromDataQueryResponses(r *http.Request, args *CreateContractsFromDataQueryResponsesArgs, response *CreateContractsFromDataQueryResponsesResponse) error

CreateContractsFromDataQueryResponses creates contracts from the available data query responses. If AllowResponseOnlyFromPeer is given the contract will be created for the specific storage provider. If not, then it will try to combine different contracts if missing files are across multiple storage providers. If some of the files were not found from any storage provider, it will fail.

func (*DataTransferAPI) CreateTransactionsWithDataPayloadFromContractHashes

func (api *DataTransferAPI) CreateTransactionsWithDataPayloadFromContractHashes(_ *http.Request, args *CreateTransactionDataPayloadFromContractHashesArgs, response *CreateTransactionDataPayloadFromContractHashesResponse) error

CreateTransactionsWithDataPayloadFromContractHashes given a list of contract hashes it creates the transactions and its data payloads.

func (*DataTransferAPI) DiscoverDownloadMediaFileRequest added in v1.2.0

func (api *DataTransferAPI) DiscoverDownloadMediaFileRequest(r *http.Request, args *DiscoverDownloadMediaFileRequestArgs, response *DiscoverDownloadMediaFileRequestResponse) error

DiscoverDownloadMediaFileRequest discovers and download media files below or equal to 512KB. this is useful for displaying images within the network.

func (*DataTransferAPI) DownloadFile

func (api *DataTransferAPI) DownloadFile(r *http.Request, args *DownloadFileArgs, response *DownloadFileResponse) error

DownloadFile downloads a file from a contract.

func (*DataTransferAPI) DownloadFileProgress

func (api *DataTransferAPI) DownloadFileProgress(_ *http.Request, args *DownloadFileProgressArgs, response *DownloadFileProgressResponse) error

DownloadFileProgress returns the download progress of a file.

func (*DataTransferAPI) GetDownloadContract

func (api *DataTransferAPI) GetDownloadContract(_ *http.Request, args *GetDownloadContractArgs, response *GetDownloadContractResponse) error

GetDownloadContract returns a contract from the memmory.

func (*DataTransferAPI) MoveDirectDownloadsToDestination added in v1.1.22

func (api *DataTransferAPI) MoveDirectDownloadsToDestination(_ *http.Request, args *MoveDirectDownloadsToDestinationArgs, response *MoveDirectDownloadsToDestinationResponse) error

MoveDirectDownloadsToDestination moves the downloaded files to final destination. These files were directly downloaded from a storage provider with zero fee, so no decryption needed. The contracts were local and never went out to the network. This method was written specifically for direct downloads with zero fees.

func (*DataTransferAPI) PauseFileDownload added in v1.1.9

func (api *DataTransferAPI) PauseFileDownload(_ *http.Request, args *PauseFileDownloadArgs, _ *PauseFileDownloadResponse) error

PauseFileDownload pauses a file download.

func (*DataTransferAPI) RebroadcastDataQueryRequest added in v1.1.16

func (api *DataTransferAPI) RebroadcastDataQueryRequest(r *http.Request, args *RebroadcastDataQueryRequestArgs, response *RebroadcastDataQueryRequestResponse) error

SendDataQueryRequest sends a data query request to the network.

func (*DataTransferAPI) RequestContractTransactionVerification added in v1.1.23

func (api *DataTransferAPI) RequestContractTransactionVerification(r *http.Request, args *RequestContractTransactionVerificationArgs, response *RequestContractTransactionVerificationResponse) error

RequestContractTransactionVerification is used by a data downloader to query storage provider and data verifier about a transaction containing a contract hash.

func (*DataTransferAPI) RequestDataQueryResponseFromVerifiers

func (api *DataTransferAPI) RequestDataQueryResponseFromVerifiers(r *http.Request, args *CheckDataQueryResponseArgs, response *CheckDataQueryResponse) error

RequestDataQueryResponseFromVerifiers returns a list of data query responses by contacting the verifiers.

func (*DataTransferAPI) RequestEncryptionDataFromVerifierAndDecrypt

func (api *DataTransferAPI) RequestEncryptionDataFromVerifierAndDecrypt(r *http.Request, args *RequestEncryptionDataFromVerifierArgs, response *RequestEncryptionDataFromVerifierResponse) error

RequestEncryptionDataFromVerifierAndDecrypt requires encryption data from verifier and decrypts.

func (*DataTransferAPI) SendContractToFileHosterAndVerifier

func (api *DataTransferAPI) SendContractToFileHosterAndVerifier(r *http.Request, args *SendContractToFileHosterAndVerifierArgs, response *SendContractToFileHosterAndVerifierResponse) error

SendContractToFileHosterAndVerifier sends the contract to file hoster and verifier.

func (*DataTransferAPI) SendDataQueryRequest

func (api *DataTransferAPI) SendDataQueryRequest(r *http.Request, args *SendDataQueryRequestArgs, response *SendDataQueryRequestResponse) error

SendDataQueryRequest sends a data query request to the network.

func (*DataTransferAPI) SendFileMerkleTreeNodesToVerifier

func (api *DataTransferAPI) SendFileMerkleTreeNodesToVerifier(r *http.Request, args *SendFileMerkleTreeNodesToVerifierArgs, response *SendFileMerkleTreeNodesToVerifierResponse) error

SendFileMerkleTreeNodesToVerifier sends the merkle tree nodes of a downloaded encrypted file to verifier from the file downloader.

func (*DataTransferAPI) VerifierHasEncryptionMetadata added in v1.1.23

VerifierHasEncryptionMetadata asks the verifier if all the files encryption metadata in a contract have been transferred.

type DeleteUploadedFilesArgs added in v1.1.29

type DeleteUploadedFilesArgs struct {
	Key         string `json:"key"`
	AccessToken string `json:"access_token"`
}

DeleteUploadedFilesArgs args for deleting file uploads.

type DeleteUploadedFilesResponse added in v1.1.29

type DeleteUploadedFilesResponse struct {
	Success bool `json:"success"`
}

DeleteUploadedFilesResponse is the response of the deletion

type DiscoverDownloadMediaFileRequestArgs added in v1.2.0

type DiscoverDownloadMediaFileRequestArgs struct {
	FileHashes string `json:"file_hashes"`
}

DiscoverDownloadMediaFileRequestArgs request arguments.

type DiscoverDownloadMediaFileRequestResponse added in v1.2.0

type DiscoverDownloadMediaFileRequestResponse struct {
	DownloadedFils []string `json:"downloaded_files"`
}

DiscoverDownloadMediaFileRequestResponse is a response.

type DownloadContractJSON

type DownloadContractJSON struct {
	FileHosterResponse         DataQueryResponseJSON `json:"file_hoster_response"`
	FileRequesterNodePublicKey string                `json:"file_requester_node_public_key"`
	FileHashesNeeded           []string              `json:"file_hashes_needed"`
	FileHashesNeededSizes      []uint64              `json:"file_hashes_needed_sizes"`
	VerifierPublicKey          string                `json:"verifier_public_key"`
	VerifierFees               string                `json:"verifier_fees"`
	ContractHash               string                `json:"contract_hash"`
	VerifierSignature          string                `json:"verifier_signature"`
}

DownloadContractJSON is a download contract in JSON.

type DownloadFileArgs

type DownloadFileArgs struct {
	ContractHash string `json:"contract_hash"`
	FileHash     string `json:"file_hash"`
	ReDownload   bool   `json:"re_download"`
}

DownloadFileArgs represent args.

type DownloadFileProgressArgs

type DownloadFileProgressArgs struct {
	ContractHash string `json:"contract_hash"`
	FileHash     string `json:"file_hash"`
}

DownloadFileProgressArgs represent args.

type DownloadFileProgressResponse

type DownloadFileProgressResponse struct {
	Error             string `json:"error"`
	BytesTransferred  uint64 `json:"bytes_transferred"`
	FileConcatenation bool   `json:"file_concatenation"`
	Paused            bool   `json:"paused"`
}

DownloadFileProgressResponse represents the response of a download file progress. file_concatenation is true when all files have been reassembled into one file. This is useful to let client know when to send the merkle hashes of the downloaded file because there will be some delay collecting and writing all the parts in one file

type DownloadFileResponse

type DownloadFileResponse struct {
	Status string `json:"status"`
}

DownloadFileArgs represents a response.

type EmptyArgs

type EmptyArgs struct{}

EmptyArgs

type ExportUploadedFilesArgs added in v1.2.1

type ExportUploadedFilesArgs struct {
	AccessToken    string `json:"access_token"`
	SaveToFilePath string `json:"save_to_filepath"`
}

ExportUploadedFilesArgs args for exporting file uploads.

type ExportUploadedFilesResponse added in v1.2.1

type ExportUploadedFilesResponse struct {
	SavedFilePath string `json:"saved_filepath"`
}

ExportUploadedFilesResponse the response of uploads exporting.

type FileMetadata

type FileMetadata struct {
	Name string `json:"name"`
	Hash string `json:"hash"`
	Size uint64 `json:"size"`
	Path string `json:"path"`
}

FileMetadata represents a file metadata

type FileRanges

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

type FileUploadProgresResult added in v1.1.23

type FileUploadProgresResult struct {
	Progress int                  `json:"progress"`
	FileHash string               `json:"file_hash"`
	FilePath string               `json:"file_path"`
	Error    string               `json:"error"`
	Metadata storage.FileMetadata `json:"metadata"`
}

FileUploadProgresResult is the result of uploads.

type FileUploadProgressArgs added in v1.1.16

type FileUploadProgressArgs struct {
	Files []FileUploadProgressRequest `json:"files"`
}

FileUploadProgressArgs args for upload progress.

type FileUploadProgressRequest added in v1.1.23

type FileUploadProgressRequest struct {
	PeerID   string `json:"peer_id"`
	FilePath string `json:"file_path"`
}

FileUploadProgressRequest represents a request.

type FileUploadProgressResponse added in v1.1.16

type FileUploadProgressResponse struct {
	Files []FileUploadProgresResult `json:"files"`
}

FileUploadProgressResponse is the response of the progress.

type FilefilegoAPI

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

FilefilegoAPI represents the filefilego rpc service.

func NewFilefilegoAPI

func NewFilefilegoAPI(cfg *config.Config, node node.Interface, blockchain blockchain.Interface, host host.Host) (*FilefilegoAPI, error)

NewFilefilegoAPI creates a new filefilego API to be served using JSONRPC.

func (*FilefilegoAPI) HostInfo

func (api *FilefilegoAPI) HostInfo(_ *http.Request, _ *EmptyArgs, response *HostInfoResponse) error

HostInfo returns the node's addresses.

func (*FilefilegoAPI) Stats

func (api *FilefilegoAPI) Stats(_ *http.Request, _ *EmptyArgs, response *StatsResponse) error

Stats reports the stats of the node.

type FilesFromEntryOrFolderArgs

type FilesFromEntryOrFolderArgs struct {
	NodeHash    string `json:"node_hash"`
	CurrentPage int    `json:"current_page"`
	PageSize    int    `json:"page_size"`
	Order       string `json:"order"`
}

FilesFromEntryOrFolderArgs is a request.

type FilesFromEntryOrFolderResponse

type FilesFromEntryOrFolderResponse struct {
	Files []FileMetadata `json:"files"`
}

FilesFromEntryOrFolderResponse is a response.

type FindProvidersArgs added in v1.1.16

type FindProvidersArgs struct {
	PreferredLocation string `json:"preferred_location"`
}

FindProvidersArgs args for finding providers

type FindProvidersResponse added in v1.1.16

type FindProvidersResponse struct {
	Success bool `json:"success"`
}

FindProvidersResponse the response of the finding storage providers mechanism.

type GetByHashArgs

type GetByHashArgs struct {
	Hash string `json:"hash"`
}

GetByHashArgs represents the args of rpc request.

type GetByNumberArgs

type GetByNumberArgs struct {
	Number uint64 `json:"number"`
}

GetByNumberArgs represents the args of rpc request.

type GetDiscoveredProvidersResponse added in v1.1.16

type GetDiscoveredProvidersResponse struct {
	StorageProviders []JSONStorageProvider `json:"storage_providers"`
}

GetDiscoveredProvidersResponse is the response containing the discovered storage providers.

type GetDownloadContractArgs

type GetDownloadContractArgs struct {
	ContractHash string `json:"contract_hash"`
}

GetDownloadContractArgs represent the args.

type GetDownloadContractResponse

type GetDownloadContractResponse struct {
	Contract DownloadContractJSON `json:"contract"`
}

GetDownloadContractResponse represents the response.

type GetNodeItemArgs

type GetNodeItemArgs struct {
	NodeHash    string `json:"node_hash"`
	CurrentPage int    `json:"current_page"`
	PageSize    int    `json:"page_size"`
	Order       string `json:"order"`
	// ChildNodeItemsType denotes which types to be included in the node child items.
	ChildNodeItemsType   string `json:"child_node_items_type"`
	ExcludeChildItemType string `json:"exclude_child_item_type"`
}

GetNodeItemArgs is a response.

type GetNodeItemResponse

type GetNodeItemResponse struct {
	Node            NodeItemJSON `json:"node"`
	Root            NodeItemJSON `json:"root"`
	TotalChildNodes uint64       `json:"total_child_nodes"`
}

GetNodeItemResponse is a response.

type GetRemoteNodeCapabilitiesArgs added in v1.3.0

type GetRemoteNodeCapabilitiesArgs struct {
	PeerID string `json:"peer_id"`
}

GetRemoteNodeCapabilitiesArgs args for remote storage node.

type GetRemoteNodeCapabilitiesResponse added in v1.3.0

type GetRemoteNodeCapabilitiesResponse struct {
	Capabilities *messages.StorageCapabilitiesProto `json:"capabilities"`
}

GetRemoteNodeCapabilitiesResponse the response of a remote storage node capabilities.

type Host added in v1.4.0

type Host interface {
	Peerstore() peerstore.Peerstore
	ID() peer.ID
}

type HostInfoResponse

type HostInfoResponse struct {
	PeerID                                  string `json:"peer_id"`
	Address                                 string `json:"address"`
	NodePublicKey                           string `json:"node_public_key"`
	PeerCount                               int    `json:"peer_count"`
	ChannelCreationFeesFFGHex               string `json:"channel_creation_fees_ffg_hex"`
	RemainingChannelOperationFeesMiliFFGHex string `json:"remaining_channel_operation_fees_miliffg_hex"`
}

HostInfoResponse represents a response.

type ImportUploadedFilesArgs added in v1.2.1

type ImportUploadedFilesArgs struct {
	AccessToken string `json:"access_token"`
	FilePath    string `json:"filepath"`
}

ImportUploadedFilesArgs args for restoring file uploads.

type ImportUploadedFilesResponse added in v1.2.1

type ImportUploadedFilesResponse struct {
	Success bool `json:"success"`
}

ImportUploadedFilesResponse the response of restoring.

type JSONBlock

type JSONBlock struct {
	Number            uint64            `json:"number"`
	Timestamp         int64             `json:"timestamp"`
	Data              string            `json:"data"`
	PreviousBlockHash string            `json:"previous_block_hash"`
	Hash              string            `json:"hash"`
	Signature         string            `json:"signature"`
	MerkleHash        string            `json:"merkle_hash"`
	Transactions      []JSONTransaction `json:"transactions"`
}

JSONBlock represents the block response of rpc request.

type JSONBlockTransaction

type JSONBlockTransaction struct {
	BlockNumber uint64          `json:"block_number"`
	Timestamp   int64           `json:"timestamp"`
	Transaction JSONTransaction `json:"transaction"`
}

JSONBlockTransaction represnts the block number and a transaction.

type JSONStorageProvider added in v1.1.16

type JSONStorageProvider struct {
	StorageProviderPeerAddr string          `json:"storage_provider_peer_addr"`
	Location                string          `json:"location"`
	FeesPerByte             string          `json:"fees_per_byte"`
	PublicKey               string          `json:"public_key"`
	Hash                    string          `json:"hash"`
	Signature               string          `json:"signature"`
	Country                 *geoip2.Country `json:"country"`
	UptimeSeconds           int64           `json:"uptime_seconds"`
	StorageCapacity         uint64          `json:"storage_capacity"`
	Platform                string          `json:"platform"`
	AllowFeesOverride       bool            `json:"allow_fees_override"`
}

JSONStorageProvider is a json storage provider.

type JSONTransaction

type JSONTransaction struct {
	Hash      string `json:"hash"`
	Signature string `json:"signature"`

	PublicKey       string `json:"public_key"`
	Nounce          string `json:"nounce"`
	Data            string `json:"data"`
	From            string `json:"from"`
	To              string `json:"to"`
	Value           string `json:"value"`
	TransactionFees string `json:"transaction_fees"`
	Chain           string `json:"chain"`
}

JSONTransaction represents a json transaction.

type KeyLockUnlockLister added in v1.4.0

type KeyLockUnlockLister interface {
	Authorized(jwtToken string) (bool, keystore.UnlockedKey, error)
}

type ListAddressesResponse added in v1.1.6

type ListAddressesResponse struct {
	Addresses []string `json:"addresses"`
}

ListAddressesResponse is a key unlock response.

type ListArgs

type ListArgs struct {
	CurrentPage int    `json:"current_page"`
	PageSize    int    `json:"page_size"`
	Order       string `json:"order"`
}

ListArgs is a list args

type ListResponse

type ListResponse struct {
	Total       uint64         `json:"total"`
	CurrentPage int            `json:"current_page"`
	PageSize    int            `json:"page_size"`
	Channels    []NodeItemJSON `json:"channels"`
}

ListResponse is a list response.

type ListUploadedFilesArgs added in v1.1.19

type ListUploadedFilesArgs struct {
	CurrentPage int    `json:"current_page"`
	PageSize    int    `json:"page_size"`
	Order       string `json:"order"`
}

ListUploadedFilesArgs args for listing uploads.

type ListUploadedFilesResponse added in v1.1.19

type ListUploadedFilesResponse struct {
	Files []storage.FileMetadataWithDBKey `json:"files"`
	Total uint64                          `json:"total"`
}

ListUploadedFilesResponse the response listing uploads.

type LockAddressArgs

type LockAddressArgs struct {
	Address string `json:"address"`
	Token   string `json:"token"`
}

LockAddressArgs arguments required for locking a key.

type LockAddressResponse

type LockAddressResponse struct {
	Success bool `json:"success"`
}

LockAddressResponse is a key unlock response.

type MemPoolResponse

type MemPoolResponse struct {
	TransactionHashes []string `json:"transaction_hashes"`
}

MemPoolResponse represents the mempool hashes.

type MoveDirectDownloadsToDestinationArgs added in v1.1.22

type MoveDirectDownloadsToDestinationArgs struct {
	ContractHash      string   `json:"contract_hash"`
	FileHashes        []string `json:"file_hashes"`
	RestoredFilePaths []string `json:"restored_file_paths"`
}

MoveDirectDownloadsToDestinationArgs represents args.

type MoveDirectDownloadsToDestinationResponse added in v1.1.22

type MoveDirectDownloadsToDestinationResponse struct {
	RestoredFilePaths []string `json:"restored_file_paths"`
}

RequestEncryptionDataFromVerifierResponse represents the response.

type NetworkMessagePublisher

type NetworkMessagePublisher interface {
	PublishMessageToNetwork(ctx context.Context, topicName string, data []byte) error
}

NetworkMessagePublisher is a pub sub message broadcaster.

type NodeItemJSON added in v1.1.6

type NodeItemJSON struct {
	Name        string         `json:"name"`
	NodeHash    string         `json:"node_hash"`
	Owner       string         `json:"owner"`
	Enabled     bool           `json:"enabled"`
	NodeType    int32          `json:"node_type"`
	Attributes  []string       `json:"attributes"`
	Admins      []string       `json:"admins"`
	Posters     []string       `json:"posters"`
	Timestamp   int64          `json:"timestamp"`
	Description string         `json:"description"`
	MerkleRoot  string         `json:"merkle_root"`
	FileHash    string         `json:"file_hash"`
	Size        uint64         `json:"size"`
	ParentHash  string         `json:"parent_hash"`
	ContentType string         `json:"content_type"`
	Nodes       []NodeItemJSON `json:"nodes"`
}

NodeItemJSON represents a node item json.

type PauseFileDownloadArgs added in v1.1.9

type PauseFileDownloadArgs struct {
	ContractHash string `json:"contract_hash"`
	FileHash     string `json:"file_hash"`
}

PauseFileDownloadArgs represent args.

type PauseFileDownloadResponse added in v1.1.9

type PauseFileDownloadResponse struct{}

PauseFileDownloadResponse represent response.

type PoolResponse

type PoolResponse struct {
	BlockHashes []string `json:"block_hashes"`
}

PoolResponse represents the block pool hashes.

type PublisherNodesFinder

type PublisherNodesFinder interface {
	NetworkMessagePublisher
	FindPeers(ctx context.Context, peerIDs []peer.ID) []peer.AddrInfo
}

PublisherNodesFinder is an interface that specifies finding nodes and publishing a message to the network functionalities.

type RebroadcastDataQueryRequestArgs added in v1.1.16

type RebroadcastDataQueryRequestArgs struct {
	Hash string `json:"hash"`
}

RebroadcastDataQueryRequestArgs rebroadcasts a data query.

type RebroadcastDataQueryRequestResponse added in v1.1.16

type RebroadcastDataQueryRequestResponse struct {
	Success bool `json:"success"`
}

SendDataQueryRequestResponse is a data query hash response.

type ReceiptArgs

type ReceiptArgs struct {
	Hash string `json:"hash"`
}

ReceiptArgs receipt arguments.

type RequestContractTransactionVerificationArgs added in v1.1.23

type RequestContractTransactionVerificationArgs struct {
	ContractHash string `json:"contract_hash"`
}

RequestContractTransactionVerificationArgs represent args for RequestContractTransactionVerification.

type RequestContractTransactionVerificationResponse added in v1.1.23

type RequestContractTransactionVerificationResponse struct {
	Verified bool `json:"verified"`
}

RequestContractTransactionVerificationResponse represent response of RequestContractTransactionVerification.

type RequestEncryptionDataFromVerifierArgs

type RequestEncryptionDataFromVerifierArgs struct {
	ContractHash         string   `json:"contract_hash"`
	FileHashes           []string `json:"file_hashes"`
	FileMerkleRootHashes []string `json:"file_merkle_root_hashes"`
	RestoredFilePaths    []string `json:"restored_file_paths"`
}

RequestEncryptionDataFromVerifierArgs represents args.

type RequestEncryptionDataFromVerifierResponse

type RequestEncryptionDataFromVerifierResponse struct {
	DecryptedFilePaths []string `json:"decrypted_file_paths"`
}

RequestEncryptionDataFromVerifierResponse represents the response.

type SaveUploadedFileMetadataLocallyArgs added in v1.1.21

type SaveUploadedFileMetadataLocallyArgs struct {
	Files []storage.FileMetadata `json:"files"`
}

SaveUploadedFileMetadataLocallyArgs args for saving uploaded metadata.

type SaveUploadedFileMetadataLocallyResponse added in v1.1.21

type SaveUploadedFileMetadataLocallyResponse struct {
	Success bool `json:"success"`
}

SaveUploadedFileMetadataLocallyResponse is the response of the saving file metadata operation.

type SearchArgs

type SearchArgs struct {
	FieldScope  string `json:"field_scope"`
	Query       string `json:"query"`
	SearchType  string `json:"search_type"`
	Size        int    `json:"size"`
	CurrentPage int    `json:"current_page"`
}

SearchArgs is a search args.

type SearchResponse

type SearchResponse struct {
	Nodes []NodeItemJSON `json:"nodes"`
}

SearchResponse is a response with the search results.

type SendContractToFileHosterAndVerifierArgs

type SendContractToFileHosterAndVerifierArgs struct {
	ContractHash string `json:"contract_hash"`
}

SendContractToFileHosterAndVerifierArgs represents the args.

type SendContractToFileHosterAndVerifierResponse

type SendContractToFileHosterAndVerifierResponse struct {
	Success bool `json:"success"`
}

SendContractToFileHosterAndVerifierResponse represents a response.

type SendDataQueryRequestArgs

type SendDataQueryRequestArgs struct {
	// FileHashes is a list of comma-separated file hashes.
	FileHashes string `json:"file_hashes"`
}

SendDataQueryRequestArgs is a data query request argument.

type SendDataQueryRequestResponse

type SendDataQueryRequestResponse struct {
	Hash string `json:"hash"`
}

SendDataQueryRequestResponse is a data query hash response.

type SendFileMerkleTreeNodesToVerifierArgs

type SendFileMerkleTreeNodesToVerifierArgs struct {
	ContractHash string `json:"contract_hash"`
	FileHash     string `json:"file_hash"`
}

SendFileMerkleTreeNodesToVerifierArgs represents args.

type SendFileMerkleTreeNodesToVerifierResponse

type SendFileMerkleTreeNodesToVerifierResponse struct {
	Success bool `json:"success"`
}

SendFileMerkleTreeNodesToVerifierResponse represents a struct.

type SendRawTransactionArgs

type SendRawTransactionArgs struct {
	RawTransaction string `json:"raw_transaction"`
}

SendRawTransactionArgs is a raw transaction sent by clients.

type SendTransactionArgs

type SendTransactionArgs struct {
	AccessToken     string `json:"access_token"`
	Nounce          string `json:"nounce"`
	Data            string `json:"data"`
	From            string `json:"from"`
	To              string `json:"to"`
	Value           string `json:"value"`
	TransactionFees string `json:"transaction_fees"`
}

SendTransactionArgs represents the arguments for sending a transaction using the client keystore mechanism.

type StatsResponse

type StatsResponse struct {
	Syncing          bool   `json:"syncing"`
	BlockchainHeight uint64 `json:"blockchain_height"`
	// nolint:misspell
	HeighestBlockNumberDiscovered           uint64     `json:"heighest_block_number_discovered"`
	PeerCount                               int        `json:"peer_count"`
	PeerID                                  string     `json:"peer_id"`
	StorageEnabled                          bool       `json:"storage_enabled"`
	ChannelCreationFeesFFGHex               string     `json:"channel_creation_fees_ffg_hex"`
	RemainingChannelOperationFeesMiliFFGHex string     `json:"remaining_channel_operation_fees_miliffg_hex"`
	Verifiers                               []verifier `json:"verifiers"`
}

StatsResponse represents a syncing status

type Storage added in v1.4.0

type Storage interface {
	SaveFileMetadata(fileHash, peerID string, metadata storage.FileMetadata) error
	ExportFiles() ([]storage.FileMetadataWithDBKey, error)
	ImportFiles(string) (int, error)
	DeleteFileFromDB(key string) error
	GetFileMetadata(fileHash string, peerID string) (storage.FileMetadata, error)
	ListFiles(currentPage, pageSize int, order string) ([]storage.FileMetadataWithDBKey, uint64, error)
}

type StorageAPI added in v1.1.16

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

StorageAPI represents the storage rpc service.

func NewStorageAPI added in v1.1.16

func NewStorageAPI(host Host, keystore KeyLockUnlockLister, publisher PublisherNodesFinder, storageProtocol StorageProtocol, storageEngine Storage) (*StorageAPI, error)

NewStorageAPI creates a new storage API to be served using JSONRPC.

func (*StorageAPI) CancelUpload added in v1.1.26

func (api *StorageAPI) CancelUpload(_ *http.Request, args *CancelUploadArgs, response *CancelUploadResponse) error

CancelUpload cancels a file upload.

func (*StorageAPI) DeleteUploadedFile added in v1.1.29

func (api *StorageAPI) DeleteUploadedFile(_ *http.Request, args *DeleteUploadedFilesArgs, response *DeleteUploadedFilesResponse) error

DeleteUploadedFile deletes the uploaded file from the node.

func (*StorageAPI) ExportUploadedFiles added in v1.2.1

func (api *StorageAPI) ExportUploadedFiles(_ *http.Request, args *ExportUploadedFilesArgs, response *ExportUploadedFilesResponse) error

ExportUploadedFiles exports the uploaded file to the given destination folder.

func (*StorageAPI) FileUploadsProgress added in v1.1.23

func (api *StorageAPI) FileUploadsProgress(_ *http.Request, args *FileUploadProgressArgs, response *FileUploadProgressResponse) error

FileUploadsProgress show the file upload progress and errors.

func (*StorageAPI) FindProviders added in v1.1.16

func (api *StorageAPI) FindProviders(_ *http.Request, args *FindProvidersArgs, response *FindProvidersResponse) error

FindProviders reports the stats of the node.

func (*StorageAPI) FindProvidersFromPeers added in v1.1.29

func (api *StorageAPI) FindProvidersFromPeers(r *http.Request, _ *EmptyArgs, response *FindProvidersResponse) error

FindProvidersFromPeers connects to other peers (mostly validators) and gets their discovered peers. nolint:revive

func (*StorageAPI) GetDiscoveredProviders added in v1.1.16

func (api *StorageAPI) GetDiscoveredProviders(_ *http.Request, _ *EmptyArgs, response *GetDiscoveredProvidersResponse) error

GetDiscoveredProviders returns a list of discovered storage providers.

func (*StorageAPI) GetRemoteNodeCapabilities added in v1.3.0

func (api *StorageAPI) GetRemoteNodeCapabilities(r *http.Request, args *GetRemoteNodeCapabilitiesArgs, response *GetRemoteNodeCapabilitiesResponse) error

GetRemoteNodeCapabilities returns the remote storage node's capabilities to the caller.

func (*StorageAPI) ImportUploadedFiles added in v1.2.1

func (api *StorageAPI) ImportUploadedFiles(_ *http.Request, args *ImportUploadedFilesArgs, response *ImportUploadedFilesResponse) error

ImportUploadedFiles restores the uploaded files.

func (*StorageAPI) ListUploadedFiles added in v1.1.19

func (api *StorageAPI) ListUploadedFiles(_ *http.Request, args *ListUploadedFilesArgs, response *ListUploadedFilesResponse) error

ListUploadedFiles lists the uploaded files on this node.

func (*StorageAPI) SaveUploadedFileMetadataLocally added in v1.1.21

func (api *StorageAPI) SaveUploadedFileMetadataLocally(_ *http.Request, args *SaveUploadedFileMetadataLocallyArgs, response *SaveUploadedFileMetadataLocallyResponse) error

SaveUploadedFileMetadataLocally saves a file metadata locally. This is useful when a file is uploaded to other nodes, and the uploading node wants to keep track of where and what has been uploaded to remote nodes.

func (*StorageAPI) Start added in v1.1.21

func (api *StorageAPI) Start()

Start starts the workers in the background for handling data uploading.

func (*StorageAPI) Stop added in v1.1.21

func (api *StorageAPI) Stop()

Stop the workers and gracefully shuts down the worker goroutines.

func (*StorageAPI) TestSpeedWithRemotePeer added in v1.1.16

func (api *StorageAPI) TestSpeedWithRemotePeer(_ *http.Request, args *TestSpeedWithRemotePeerArgs, response *TestSpeedWithRemotePeerResponse) error

TestSpeedWithRemotePeer tests the remote peer speed.

func (*StorageAPI) UploadFileToProvider added in v1.1.16

func (api *StorageAPI) UploadFileToProvider(_ *http.Request, args *UploadFileToProviderArgs, response *UploadFileToProviderResponse) error

UploadFileToProvider uploads a file to provider.

type StorageProtocol added in v1.4.0

type StorageProtocol interface {
	ResetProgressAndCancelStatus(peerID peer.ID, filePath string)
	GetCancelFileUploadStatus(peerID peer.ID, filePath string) (bool, context.CancelFunc)
	SetCancelFileUpload(peerID peer.ID, filePath string, cancelled bool, cancel context.CancelFunc)
	GetStorageCapabilities(ctx context.Context, peerID peer.ID) (*messages.StorageCapabilitiesProto, error)
	TestSpeedWithRemotePeer(ctx context.Context, peerID peer.ID, fileSize uint64) (time.Duration, error)
	UploadFileWithMetadata(ctx context.Context, peerID peer.ID, filePath string, publicKeyOwner []byte, feesPerByte string) (storage.FileMetadata, error)
	GetDiscoveredStorageProviders() []storageprotocol.ProviderWithCountry
	GetUploadProgress(peerID peer.ID, filePath string) (int, string, error)
	SetUploadingStatus(peerID peer.ID, filePath, fileHash string, err error)
	SendDiscoveredStorageTransferRequest(ctx context.Context, peerID peer.ID) (int, error)
}

type TestSpeedWithRemotePeerArgs added in v1.1.16

type TestSpeedWithRemotePeerArgs struct {
	PeerID   string `json:"peer_id"`
	FileSize uint64 `json:"file_size"`
}

TestSpeedWithRemotePeerArgs args for testing speed.

type TestSpeedWithRemotePeerResponse added in v1.1.16

type TestSpeedWithRemotePeerResponse struct {
	DownloadThroughputMB float64 `json:"download_throughput_mb"`
}

TestSpeedWithRemotePeerResponse the response of the speed test.

type TransactionAPI

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

TransactionAPI represents the transaction rpc service.

func NewTransactionAPI

func NewTransactionAPI(keystore keystore.KeyAuthorizer, publisher NetworkMessagePublisher, blockchain Blockchain, superLightNode bool) (*TransactionAPI, error)

NewTransactionAPI creates a new transaction API to be served using JSONRPC.

func (*TransactionAPI) ByAddress

func (api *TransactionAPI) ByAddress(_ *http.Request, args *ByAddressArgs, response *TransactionsResponse) error

ByAddress gets the list of transactions by address.

func (*TransactionAPI) CreateTransaction added in v1.1.29

func (api *TransactionAPI) CreateTransaction(_ *http.Request, args *SendTransactionArgs, response *TransactionResponse) error

CreateTransaction creates a transaction and returns the json encoded payload. it uses the same arguments as SendTransactionArgs. this method is used for a client to create and sign and a transaction without broadcasting it to the network.

func (*TransactionAPI) Pool

func (api *TransactionAPI) Pool(_ *http.Request, _ *EmptyArgs, response *MemPoolResponse) error

Pool gets the list of transactions in mempool.

func (*TransactionAPI) Receipt

func (api *TransactionAPI) Receipt(_ *http.Request, args *ReceiptArgs, response *TransactionsResponse) error

Receipt gets the transaction receipt.

func (*TransactionAPI) SendRawTransaction

func (api *TransactionAPI) SendRawTransaction(r *http.Request, args *SendRawTransactionArgs, response *TransactionResponse) error

SendRawTransaction sends a raw transaction.

func (*TransactionAPI) SendTransaction

func (api *TransactionAPI) SendTransaction(r *http.Request, args *SendTransactionArgs, response *TransactionResponse) error

SendTransaction sends a transaction.

type TransactionResponse

type TransactionResponse struct {
	Transaction JSONTransaction `json:"transaction"`
}

TransactionResponse represents a response with a transaction.

type TransactionsResponse

type TransactionsResponse struct {
	Transactions []JSONBlockTransaction `json:"transactions"`
}

TransactionsResponse represents a response with block and transaction

type UnlockAddressArgs

type UnlockAddressArgs struct {
	Address    string `json:"address"`
	Passphrase string `json:"passphrase"`
}

UnlockAddressArgs arguments required for unlocking a key.

type UnlockAddressResponse

type UnlockAddressResponse struct {
	Token string `json:"token"`
}

UnlockAddressResponse is a key unlock response.

type UploadFileToProviderArgs added in v1.1.16

type UploadFileToProviderArgs struct {
	Files []UploadFileToProviderRequest `json:"files"`
}

UploadFileToProviderArgs args for uploading to a provider.

type UploadFileToProviderRequest added in v1.1.23

type UploadFileToProviderRequest struct {
	PeerID         string `json:"peer_id"`
	FilePath       string `json:"file_path"`
	PublicKeyOwner string `json:"public_key_owner"`
	FeesPerByte    string `json:"fees_per_byte"`
}

UploadFileToProviderRequest

type UploadFileToProviderResponse added in v1.1.16

type UploadFileToProviderResponse struct {
	Success bool `json:"success"`
}

UploadFileToProviderResponse is the response of the uploaded file to provider.

type VerifierHasEncryptionMetadataArgs added in v1.1.23

type VerifierHasEncryptionMetadataArgs struct {
	ContractHash string `json:"contract_hash"`
}

VerifierHasEncryptionMetadataArgs represent args for VerifierHasEncryptionMetadataArgs.

type VerifierHasEncryptionMetadataResponse added in v1.1.23

type VerifierHasEncryptionMetadataResponse struct {
	Verified bool `json:"verified"`
}

VerifierHasEncryptionMetadataResponse represent response of VerifierHasEncryptionMetadataResponse.

Jump to

Keyboard shortcuts

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