client

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2018 License: MIT Imports: 16 Imported by: 29

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 siad server.
	Address string

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

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

A Client makes requests to the siad HTTP API.

func New

func New(address string) *Client

New creates a new Client using the provided address.

func (*Client) ConsensusBlocksHeightGet added in v1.3.3

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

ConsensusBlocksHeightGet requests the /consensus/blocks api resource

func (*Client) ConsensusBlocksIDGet added in v1.3.3

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 added in v1.3.3

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

DaemonUpdateGet checks for an available daemon update.

func (*Client) DaemonUpdatePost added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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

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

func (*Client) HostDbGet added in v1.3.3

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

HostDbGet requests the /hostdb endpoint's resources.

func (*Client) HostDbHostsGet added in v1.3.3

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

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

func (*Client) HostEstimateScoreGet added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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

HostStorageGet requests the /host/storage endpoint.

func (*Client) HostStorageSectorsDeletePost added in v1.3.3

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 added in v1.3.3

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) NewRequest

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

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

func (*Client) RenterCancelAllowance added in v1.3.3

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

RenterCancelAllowance uses the /renter endpoint to cancel the allowance.

func (*Client) RenterClearAllDownloadsPost added in v1.3.4

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

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

func (*Client) RenterClearDownloadsAfterPost added in v1.3.4

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 added in v1.3.4

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 added in v1.3.4

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) 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) RenterDownloadFullGet added in v1.3.3

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 added in v1.3.4

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 added in v1.3.3

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

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

func (*Client) RenterFilesGet

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

RenterFilesGet requests the /renter/files resource.

func (*Client) RenterGet added in v1.3.3

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

RenterGet requests the /renter resource.

func (*Client) RenterInactiveContractsGet added in v1.3.4

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 added in v1.3.3

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

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

func (*Client) RenterPostRateLimit added in v1.3.3

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 added in v1.3.3

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

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

func (*Client) RenterRenamePost added in v1.3.3

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

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

func (*Client) RenterSetStreamCacheSizePost added in v1.3.3

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

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

func (*Client) RenterStreamGet added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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) TransactionPoolFeeGet added in v1.3.3

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

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

func (*Client) TransactionPoolRawPost added in v1.3.3

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) Wallet033xPost added in v1.3.3

func (c *Client) Wallet033xPost(path, password string) (err error)

Wallet033xPost uses the /wallet/033x endpoint to load a v0.3.3.x wallet into the current wallet.

func (*Client) WalletAddressGet

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

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

func (*Client) WalletAddressesGet added in v1.3.3

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

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

func (*Client) WalletChangePasswordPost added in v1.3.3

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 added in v1.3.3

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 added in v1.3.3

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

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

func (*Client) WalletSeedPost added in v1.3.3

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 added in v1.3.3

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/siacoins api endpoint to send money to a single address

func (*Client) WalletSiafundsPost added in v1.3.3

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

WalletSiafundsPost uses the /wallet/siafunds api endpoint to send siafunds to a single address.

func (*Client) WalletSiagKeyPost added in v1.3.3

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) WalletSweepPost added in v1.3.3

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 added in v1.3.3

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) 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.

type HostParam added in v1.3.3

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