client

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2018 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// HostParamCollateralBudget is the collateral budget of the host in
	// hastings.
	HostParamCollateralBudget = HostParam("collateralbudget")
	// HostParamMaxCollateral is the max collateral of the host in hastings.
	HostParamMaxCollateral = HostParam("maxcollateral")
	// HostParamMinContractPrice is the min contract price in hastings.
	HostParamMinContractPrice = HostParam("mincontractprice")
	// HostParamMinDownloadBandwidthPrice is the min download bandwidth price
	// in hastings/byte.
	HostParamMinDownloadBandwidthPrice = HostParam("mindownloadbandwidthprice")
	// HostParamMinUploadBandwidthPrice is the min upload bandwidth price in
	// hastings/byte.
	HostParamMinUploadBandwidthPrice = HostParam("minuploadbandwidthprice")
	// HostParamCollateral is the host's collateral in hastings/byte/block.
	HostParamCollateral = HostParam("collateral")
	// HostParamMinStoragePrice is the minimum storage price in
	// hastings/byte/block.
	HostParamMinStoragePrice = HostParam("minstorageprice")
	// HostParamAcceptingContracts indicates if the host is accepting new
	// contracts.
	HostParamAcceptingContracts = HostParam("acceptingcontracts")
	// HostParamMaxDuration is the max duration of a contract in blocks.
	HostParamMaxDuration = HostParam("maxduration")
	// HostParamWindowSize is the size of the proof window in blocks.
	HostParamWindowSize = HostParam("windowsize")
	// HostParamMaxDownloadBatchSize is the maximum size of the download batch
	// size in bytes.
	HostParamMaxDownloadBatchSize = HostParam("maxdownloadbatchsize")
	// HostParamMaxReviseBatchSize is the maximum size of the revise batch size.
	HostParamMaxReviseBatchSize = HostParam("maxrevisebatchsize")
	// HostParamNetAddress is the announced netaddress of the host.
	HostParamNetAddress = HostParam("netaddress")
)

Variables

View Source
var (
	// ErrPeerExists indicates that two peers are already connected. The string
	// of this error needs to be updated if the string of errPeerExists in the
	// gateway package is changed.
	ErrPeerExists = errors.New("already connected to this peer")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// Address is the API address of the hsd server.
	Address string

	// Password must match the password of the hsd server.
	Password string

	// UserAgent must match the User-Agent required by the hsd server. If not
	// set, it defaults to "Hyperspace-Agent".
	UserAgent string
}

A Client makes requests to the hsd HTTP API.

func New

func New(address string) *Client

New creates a new Client using the provided address.

func (*Client) ConsensusBlocksHeightGet

func (c *Client) ConsensusBlocksHeightGet(height types.BlockHeight) (cbg api.ConsensusBlocksGet, err error)

ConsensusBlocksHeightGet requests the /consensus/blocks api resource

func (*Client) ConsensusBlocksIDGet

func (c *Client) ConsensusBlocksIDGet(id types.BlockID) (cbg api.ConsensusBlocksGet, err error)

ConsensusBlocksIDGet requests the /consensus/blocks api resource

func (*Client) ConsensusGet

func (c *Client) ConsensusGet() (cg api.ConsensusGET, err error)

ConsensusGet requests the /consensus api resource

func (*Client) DaemonStopGet

func (c *Client) DaemonStopGet() (err error)

DaemonStopGet stops the daemon using the /daemon/stop endpoint.

func (*Client) DaemonUpdateGet

func (c *Client) DaemonUpdateGet() (dig api.DaemonUpdateGet, err error)

DaemonUpdateGet checks for an available daemon update.

func (*Client) DaemonUpdatePost

func (c *Client) DaemonUpdatePost() (err error)

DaemonUpdatePost updates the daemon.

func (*Client) DaemonVersionGet

func (c *Client) DaemonVersionGet() (dvg api.DaemonVersionGet, err error)

DaemonVersionGet requests the /daemon/version resource

func (*Client) GatewayConnectPost

func (c *Client) GatewayConnectPost(address modules.NetAddress) (err error)

GatewayConnectPost uses the /gateway/connect/:address endpoint to connect to the gateway at address

func (*Client) GatewayDisconnectPost

func (c *Client) GatewayDisconnectPost(address modules.NetAddress) (err error)

GatewayDisconnectPost uses the /gateway/disconnect/:address endpoint to disconnect the gateway from a peer.

func (*Client) GatewayGet

func (c *Client) GatewayGet() (gwg api.GatewayGET, err error)

GatewayGet requests the /gateway api resource

func (*Client) HostAnnounceAddrPost

func (c *Client) HostAnnounceAddrPost(address modules.NetAddress) (err error)

HostAnnounceAddrPost uses the /host/anounce endpoint to announce the host to the network using the provided address.

func (*Client) HostAnnouncePost

func (c *Client) HostAnnouncePost() (err error)

HostAnnouncePost uses the /host/announce endpoint to announce the host to the network

func (*Client) HostContractInfoGet

func (c *Client) HostContractInfoGet() (cg api.ContractInfoGET, err error)

HostContractInfoGet uses the /host/contracts endpoint to get information about contracts on the host.

func (*Client) HostDbActiveGet

func (c *Client) HostDbActiveGet() (hdag api.HostdbActiveGET, err error)

HostDbActiveGet requests the /hostdb/active endpoint's resources.

func (*Client) HostDbAllGet

func (c *Client) HostDbAllGet() (hdag api.HostdbAllGET, err error)

HostDbAllGet requests the /hostdb/all endpoint's resources.

func (*Client) HostDbGet

func (c *Client) HostDbGet() (hdg api.HostdbGet, err error)

HostDbGet requests the /hostdb endpoint's resources.

func (*Client) HostDbHostsGet

func (c *Client) HostDbHostsGet(pk types.SiaPublicKey) (hhg api.HostdbHostsGET, err error)

HostDbHostsGet request the /hostdb/hosts/:pubkey endpoint's resources.

func (*Client) HostEstimateScoreGet

func (c *Client) HostEstimateScoreGet(param, value string) (eg api.HostEstimateScoreGET, err error)

HostEstimateScoreGet requests the /host/estimatescore endpoint.

func (*Client) HostGet

func (c *Client) HostGet() (hg api.HostGET, err error)

HostGet requests the /host endpoint.

func (*Client) HostModifySettingPost

func (c *Client) HostModifySettingPost(param HostParam, value interface{}) (err error)

HostModifySettingPost uses the /host endpoint to change a param of the host settings to a certain value.

func (*Client) HostStorageFoldersAddPost

func (c *Client) HostStorageFoldersAddPost(path string, size uint64) (err error)

HostStorageFoldersAddPost uses the /host/storage/folders/add api endpoint to add a storage folder to a host

func (*Client) HostStorageFoldersRemovePost

func (c *Client) HostStorageFoldersRemovePost(path string) (err error)

HostStorageFoldersRemovePost uses the /host/storage/folders/remove api endpoint to remove a storage folder from a host.

func (*Client) HostStorageFoldersResizePost

func (c *Client) HostStorageFoldersResizePost(path string, size uint64) (err error)

HostStorageFoldersResizePost uses the /host/storage/folders/resize api endpoint to resize an existing storage folder.

func (*Client) HostStorageGet

func (c *Client) HostStorageGet() (sg api.StorageGET, err error)

HostStorageGet requests the /host/storage endpoint.

func (*Client) HostStorageSectorsDeletePost

func (c *Client) HostStorageSectorsDeletePost(root crypto.Hash) (err error)

HostStorageSectorsDeletePost uses the /host/storage/sectors/delete endpoint to delete a sector from the host.

func (*Client) MinerGet

func (c *Client) MinerGet() (mg api.MinerGET, err error)

MinerGet requests the /miner endpoint's resources.

func (*Client) MinerHeaderGet

func (c *Client) MinerHeaderGet() (target types.Target, bh types.BlockHeader, err error)

MinerHeaderGet uses the /miner/header endpoint to get a header for work.

func (*Client) MinerHeaderPost

func (c *Client) MinerHeaderPost(bh types.BlockHeader) (err error)

MinerHeaderPost uses the /miner/header endpoint to submit a solved block header that was previously received from the same endpoint

func (*Client) MinerStartGet

func (c *Client) MinerStartGet() (err error)

MinerStartGet uses the /miner/start endpoint to start the cpu miner.

func (*Client) MinerStopGet

func (c *Client) MinerStopGet() (err error)

MinerStopGet uses the /miner/stop endpoint to stop the cpu miner.

func (*Client) MiningPoolClientsGet

func (c *Client) MiningPoolClientsGet() (clientInfos api.MiningPoolClientsInfo, err error)

MiningPoolClientsGet requests the /pool/clients client info list.

func (*Client) MiningPoolConfigGet

func (c *Client) MiningPoolConfigGet() (config api.MiningPoolConfig, err error)

MiningPoolConfigGet requests the /pool/config configuration info.

func (*Client) MiningPoolConfigPost

func (c *Client) MiningPoolConfigPost(key string, val string) (err error)

MiningPoolConfigPost uses the /pool/config endpoint to tell mining pool to use a new configuration value

func (*Client) MiningPoolGet

func (c *Client) MiningPoolGet() (mg api.MiningPoolGET, err error)

MiningPoolGet requests the /pool endpoint's resources.

func (*Client) NewRequest

func (c *Client) NewRequest(method, resource string, body io.Reader) (*http.Request, error)

NewRequest constructs a request to the hsd HTTP API, setting the correct User-Agent and Basic Auth. The resource path must begin with /.

func (*Client) RenterCancelAllowance

func (c *Client) RenterCancelAllowance() (err error)

RenterCancelAllowance uses the /renter endpoint to cancel the allowance.

func (*Client) RenterClearAllDownloadsPost

func (c *Client) RenterClearAllDownloadsPost() (err error)

RenterClearAllDownloadsPost requests the /renter/downloads/clear resource with no parameters

func (*Client) RenterClearDownloadsAfterPost

func (c *Client) RenterClearDownloadsAfterPost(after time.Time) (err error)

RenterClearDownloadsAfterPost requests the /renter/downloads/clear resource with only the after timestamp provided

func (*Client) RenterClearDownloadsBeforePost

func (c *Client) RenterClearDownloadsBeforePost(before time.Time) (err error)

RenterClearDownloadsBeforePost requests the /renter/downloads/clear resource with only the before timestamp provided

func (*Client) RenterClearDownloadsRangePost

func (c *Client) RenterClearDownloadsRangePost(after, before time.Time) (err error)

RenterClearDownloadsRangePost requests the /renter/downloads/clear resource with both before and after timestamps provided

func (*Client) RenterContractCancelPost

func (c *Client) RenterContractCancelPost(id types.FileContractID) error

RenterContractCancelPost uses the /renter/contract/cancel endpoint to cancel a contract

func (*Client) RenterContractsGet

func (c *Client) RenterContractsGet() (rc api.RenterContracts, err error)

RenterContractsGet requests the /renter/contracts resource and returns Contracts and ActiveContracts

func (*Client) RenterDeletePost

func (c *Client) RenterDeletePost(siaPath string) (err error)

RenterDeletePost uses the /renter/delete endpoint to delete a file.

func (*Client) RenterDirCreatePost

func (c *Client) RenterDirCreatePost(siaPath string) (err error)

RenterDirCreatePost uses the /renter/dir/ endpoint to create a directory for the renter

func (*Client) RenterDirDeletePost

func (c *Client) RenterDirDeletePost(siaPath string) (err error)

RenterDirDeletePost uses the /renter/dir/ endpoint to delete a directory for the renter

func (*Client) RenterDirRenamePost

func (c *Client) RenterDirRenamePost(siaPath, newHyperspacePath string) (err error)

RenterDirRenamePost uses the /renter/dir/ endpoint to rename a directory for the renter

func (*Client) RenterDownloadFullGet

func (c *Client) RenterDownloadFullGet(siaPath, destination string, async bool) (err error)

RenterDownloadFullGet uses the /renter/download endpoint to download a full file.

func (*Client) RenterDownloadGet

func (c *Client) RenterDownloadGet(siaPath, destination string, offset, length uint64, async bool) (err error)

RenterDownloadGet uses the /renter/download endpoint to download a file to a destination on disk.

func (*Client) RenterDownloadHTTPResponseGet

func (c *Client) RenterDownloadHTTPResponseGet(siaPath string, offset, length uint64) (resp []byte, err error)

RenterDownloadHTTPResponseGet uses the /renter/download endpoint to download a file and return its data.

func (*Client) RenterDownloadsGet

func (c *Client) RenterDownloadsGet() (rdq api.RenterDownloadQueue, err error)

RenterDownloadsGet requests the /renter/downloads resource

func (*Client) RenterExpiredContractsGet

func (c *Client) RenterExpiredContractsGet() (rc api.RenterContracts, err error)

RenterExpiredContractsGet requests the /renter/contracts resource with the expired flag set to true

func (*Client) RenterFileGet

func (c *Client) RenterFileGet(siaPath string) (rf api.RenterFile, err error)

RenterFileGet uses the /renter/file/:hyperspacepath endpoint to query a file.

func (*Client) RenterFilesFilteredGet

func (c *Client) RenterFilesFilteredGet(filter string) (rf api.RenterFiles, err error)

RenterFilesFilteredGet requests the /renter/files resource with a regex filter string.

func (*Client) RenterFilesGet

func (c *Client) RenterFilesGet() (rf api.RenterFiles, err error)

RenterFilesGet requests the /renter/files resource.

func (*Client) RenterGet

func (c *Client) RenterGet() (rg api.RenterGET, err error)

RenterGet requests the /renter resource.

func (*Client) RenterInactiveContractsGet

func (c *Client) RenterInactiveContractsGet() (rc api.RenterContracts, err error)

RenterInactiveContractsGet requests the /renter/contracts resource with the inactive flag set to true

func (*Client) RenterPostAllowance

func (c *Client) RenterPostAllowance(allowance modules.Allowance) (err error)

RenterPostAllowance uses the /renter endpoint to change the renter's allowance

func (*Client) RenterPostRateLimit

func (c *Client) RenterPostRateLimit(readBPS, writeBPS int64) (err error)

RenterPostRateLimit uses the /renter endpoint to change the renter's bandwidth rate limit.

func (*Client) RenterPricesGet

func (c *Client) RenterPricesGet() (rpg api.RenterPricesGET, err error)

RenterPricesGet requests the /renter/prices endpoint's resources.

func (*Client) RenterRenamePost

func (c *Client) RenterRenamePost(siaPathOld, siaPathNew string) (err error)

RenterRenamePost uses the /renter/rename/:hyperspacepath endpoint to rename a file.

func (*Client) RenterSetRepairPathPost

func (c *Client) RenterSetRepairPathPost(siaPath, newPath string) (err error)

RenterSetRepairPathPost uses the /renter/tracking endpoint to set the repair path of a file to a new location. The file at newPath must exists.

func (*Client) RenterSetStreamCacheSizePost

func (c *Client) RenterSetStreamCacheSizePost(cacheSize uint64) (err error)

RenterSetStreamCacheSizePost uses the /renter endpoint to change the renter's streamCacheSize for streaming

func (*Client) RenterStreamGet

func (c *Client) RenterStreamGet(siaPath string) (resp []byte, err error)

RenterStreamGet uses the /renter/stream endpoint to download data as a stream.

func (*Client) RenterStreamPartialGet

func (c *Client) RenterStreamPartialGet(siaPath string, start, end uint64) (resp []byte, err error)

RenterStreamPartialGet uses the /renter/stream endpoint to download a part of data as a stream.

func (*Client) RenterUploadDefaultPost

func (c *Client) RenterUploadDefaultPost(path, siaPath string) (err error)

RenterUploadDefaultPost uses the /renter/upload endpoint with default redundancy settings to upload a file.

func (*Client) RenterUploadPost

func (c *Client) RenterUploadPost(path, siaPath string, dataPieces, parityPieces uint64) (err error)

RenterUploadPost uses the /renter/upload endpoint to upload a file

func (*Client) StratumMinerGet

func (c *Client) StratumMinerGet() (mg api.StratumMinerGET, err error)

StratumMinerGet requests the /stratumminer endpoint's resources.

func (*Client) StratumMinerStartPost

func (c *Client) StratumMinerStartPost(server, username string) (err error)

StratumMinerStartPost uses the /stratumminer/start endpoint to start the stratum miner.

func (*Client) StratumMinerStopPost

func (c *Client) StratumMinerStopPost() (err error)

StratumMinerStopGet uses the /stratumminer/stop endpoint to stop the stratum miner.

func (*Client) TransactionPoolFeeGet

func (c *Client) TransactionPoolFeeGet() (tfg api.TpoolFeeGET, err error)

TransactionPoolFeeGet uses the /tpool/fee endpoint to get a fee estimation.

func (*Client) TransactionPoolRawPost

func (c *Client) TransactionPoolRawPost(txn types.Transaction, parents []types.Transaction) (err error)

TransactionPoolRawPost uses the /tpool/raw endpoint to send a raw transaction to the transaction pool.

func (*Client) WalletAddressGet

func (c *Client) WalletAddressGet() (wag api.WalletAddressGET, err error)

WalletAddressGet requests an unused address from the /wallet/address endpoint

func (*Client) WalletAddressPost

func (c *Client) WalletAddressPost() (wap api.WalletAddressPOST, err error)

WalletAddressPost requests a new address from the /wallet/address endpoint

func (*Client) WalletAddressesGet

func (c *Client) WalletAddressesGet() (wag api.WalletAddressesGET, err error)

WalletAddressesGet requests the wallets known addresses from the /wallet/addresses endpoint.

func (*Client) WalletBuildTransactionGet

func (c *Client) WalletBuildTransactionGet(destination types.UnlockHash, amount types.Currency) (wbtg api.WalletBuildTransactionGET, err error)

WalletBuildTransactionGet requests the /wallet/transactions/build api resource for a certain destiniation and amount

func (*Client) WalletChangePasswordPost

func (c *Client) WalletChangePasswordPost(currentPassword, newPassword string) (err error)

WalletChangePasswordPost uses the /wallet/changepassword endpoint to change the wallet's password.

func (*Client) WalletGet

func (c *Client) WalletGet() (wg api.WalletGET, err error)

WalletGet requests the /wallet api resource

func (*Client) WalletInitPost

func (c *Client) WalletInitPost(password string, force bool) (wip api.WalletInitPOST, err error)

WalletInitPost uses the /wallet/init endpoint to initialize and encrypt a wallet

func (*Client) WalletInitSeedPost

func (c *Client) WalletInitSeedPost(seed, password string, force bool) (err error)

WalletInitSeedPost uses the /wallet/init/seed endpoint to initialize and encrypt a wallet using a given seed.

func (*Client) WalletLockPost

func (c *Client) WalletLockPost() (err error)

WalletLockPost uses the /wallet/lock endpoint to lock the wallet.

func (*Client) WalletSeedPost

func (c *Client) WalletSeedPost(seed, password string) (err error)

WalletSeedPost uses the /wallet/seed endpoint to add a seed to the wallet's list of seeds.

func (*Client) WalletSeedsGet

func (c *Client) WalletSeedsGet() (wsg api.WalletSeedsGET, err error)

WalletSeedsGet uses the /wallet/seeds endpoint to return the wallet's current seeds.

func (*Client) WalletSiacoinsMultiPost

func (c *Client) WalletSiacoinsMultiPost(outputs []types.SiacoinOutput) (wsp api.WalletSiacoinsPOST, err error)

WalletSiacoinsMultiPost uses the /wallet/siacoin api endpoint to send money to multiple addresses at once

func (*Client) WalletSiacoinsPost

func (c *Client) WalletSiacoinsPost(amount types.Currency, destination types.UnlockHash) (wsp api.WalletSiacoinsPOST, err error)

WalletSiacoinsPost uses the /wallet/spacecash api endpoint to send money to a single address

func (*Client) WalletSiagKeyPost

func (c *Client) WalletSiagKeyPost(keyfiles, password string) (err error)

WalletSiagKeyPost uses the /wallet/siagkey endpoint to load a siag key into the wallet.

func (*Client) WalletSignPost

func (c *Client) WalletSignPost(txn types.Transaction, toSign []crypto.Hash) (wspr api.WalletSignPOSTResp, err error)

WalletSignPost uses the /wallet/sign api endpoint to sign a transaction.

func (*Client) WalletSweepPost

func (c *Client) WalletSweepPost(seed string) (wsp api.WalletSweepPOST, err error)

WalletSweepPost uses the /wallet/sweep/seed endpoint to sweep a seed into the current wallet.

func (*Client) WalletTransactionGet

func (c *Client) WalletTransactionGet(id types.TransactionID) (wtg api.WalletTransactionGETid, err error)

WalletTransactionGet requests the /wallet/transaction/:id api resource for a certain TransactionID.

func (*Client) WalletTransactionsGet

func (c *Client) WalletTransactionsGet(startHeight types.BlockHeight, endHeight types.BlockHeight) (wtg api.WalletTransactionsGET, err error)

WalletTransactionsGet requests the/wallet/transactions api resource for a certain startheight and endheight

func (*Client) WalletUnlockConditionsGet

func (c *Client) WalletUnlockConditionsGet(addr types.UnlockHash) (wucg api.WalletUnlockConditionsGET, err error)

WalletUnlockConditionsGet requests the /wallet/unlockconditions endpoint and returns the UnlockConditions of addr.

func (*Client) WalletUnlockPost

func (c *Client) WalletUnlockPost(password string) (err error)

WalletUnlockPost uses the /wallet/unlock endpoint to unlock the wallet with a given encryption key. Per default this key is the seed.

func (*Client) WalletUnspentGet

func (c *Client) WalletUnspentGet() (wug api.WalletUnspentGET, err error)

WalletUnspentGet requests the /wallet/unspent endpoint and returns all of the unspent outputs related to the wallet.

func (*Client) WalletWatchGet

func (c *Client) WalletWatchGet() (wwg api.WalletWatchGET, err error)

WalletWatchGet requests the /wallet/watch endpoint and returns the set of currently watched addresses.

func (*Client) WalletWatchPost

func (c *Client) WalletWatchPost(addrs []types.UnlockHash, remove, unused bool) error

WalletWatchPost uses the /wallet/watch endpoint to add or remove a set of addresses from the watch set. The unused flag should be set to true if the addresses have never appeared in the blockchain.

type HostParam

type HostParam string

HostParam is a parameter in the host's settings that can be changed via the API. It is primarily used as a helper struct to ensure type safety.

Jump to

Keyboard shortcuts

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