Documentation
¶
Index ¶
- Variables
- func IsBalanceInsufficient(err error) bool
- func IsBalanceMaxExceeded(err error) bool
- func IsClosedStream(err error) bool
- func IsErrHost(err error) bool
- func IsInsufficientFunds(err error) bool
- func IsPriceTableExpired(err error) bool
- func IsPriceTableGouging(err error) bool
- func IsPriceTableNotFound(err error) bool
- func IsSectorNotFound(err error) bool
- func IsWithdrawalExpired(err error) bool
- func IsWithdrawalsInactive(err error) bool
- type Client
- func (c *Client) AppendSector(ctx context.Context, sectorRoot types.Hash256, sector *[rhpv2.SectorSize]byte, ...) (types.Currency, error)
- func (c *Client) FundAccount(ctx context.Context, rev *types.FileContractRevision, hk types.PublicKey, ...) error
- func (c *Client) PriceTable(ctx context.Context, hk types.PublicKey, siamuxAddr string, ...) (pt api.HostPriceTable, err error)
- func (c *Client) PriceTableUnpaid(ctx context.Context, hk types.PublicKey, siamuxAddr string) (pt api.HostPriceTable, err error)
- func (c *Client) ReadSector(ctx context.Context, offset, length uint32, root types.Hash256, w io.Writer, ...) (types.Currency, error)
- func (c *Client) Renew(ctx context.Context, rrr api.RHPRenewRequest, gougingChecker gouging.Checker, ...) (newRev rhpv2.ContractRevision, txnSet []types.Transaction, ...)
- func (c *Client) Revision(ctx context.Context, fcid types.FileContractID, hk types.PublicKey, ...) (rev types.FileContractRevision, err error)
- func (c *Client) SyncAccount(ctx context.Context, rev *types.FileContractRevision, hk types.PublicKey, ...) (balance types.Currency, _ error)
- type Dialer
- type PrepareRenewFunc
- type PriceTablePaymentFunc
- type SignFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFailedToCreatePayment is returned when the client failed to pay using a contract. ErrFailedToCreatePayment = errors.New("failed to create contract payment") // errDialTransport is returned when the worker could not dial the host. ErrDialTransport = errors.New("could not dial transport") // errBalanceInsufficient occurs when a withdrawal failed because the // account balance was insufficient. ErrBalanceInsufficient = errors.New("ephemeral account balance was insufficient") // ErrMaxRevisionReached occurs when trying to revise a contract that has // already reached the highest possible revision number. Usually happens // when trying to use a renewed contract. ErrMaxRevisionReached = errors.New("contract has reached the maximum number of revisions") // ErrSectorNotFound is returned by a host when it can't find the requested // sector. ErrSectorNotFound = errors.New("sector not found") )
Functions ¶
func IsBalanceInsufficient ¶
func IsBalanceMaxExceeded ¶
func IsClosedStream ¶
func IsInsufficientFunds ¶
func IsPriceTableExpired ¶
func IsPriceTableGouging ¶
func IsPriceTableNotFound ¶
func IsSectorNotFound ¶
func IsWithdrawalExpired ¶
func IsWithdrawalsInactive ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AppendSector ¶
func (*Client) FundAccount ¶
func (*Client) PriceTable ¶
func (c *Client) PriceTable(ctx context.Context, hk types.PublicKey, siamuxAddr string, paymentFn PriceTablePaymentFunc) (pt api.HostPriceTable, err error)
func (*Client) PriceTableUnpaid ¶
func (*Client) ReadSector ¶
func (*Client) Renew ¶
func (c *Client) Renew(ctx context.Context, rrr api.RHPRenewRequest, gougingChecker gouging.Checker, renewer PrepareRenewFunc, signer SignFunc, rev types.FileContractRevision, renterKey types.PrivateKey) (newRev rhpv2.ContractRevision, txnSet []types.Transaction, contractPrice, fundAmount types.Currency, err error)
func (*Client) SyncAccount ¶
type PrepareRenewFunc ¶
type PrepareRenewFunc func(ctx context.Context, revision types.FileContractRevision, hostAddress, renterAddress types.Address, renterKey types.PrivateKey, renterFunds, minNewCollateral, maxFundAmount types.Currency, pt rhpv3.HostPriceTable, endHeight, windowSize, expectedStorage uint64) (resp api.WalletPrepareRenewResponse, discard func(context.Context, types.Transaction, *error), err error)
type PriceTablePaymentFunc ¶
type PriceTablePaymentFunc func(pt rhpv3.HostPriceTable) (rhpv3.PaymentMethod, error)
PriceTablePaymentFunc is a function that can be passed in to RPCPriceTable. It is called after the price table is received from the host and supposed to create a payment for that table and return it. It can also be used to perform gouging checks before paying for the table.
func PreparePriceTableAccountPayment ¶
func PreparePriceTableAccountPayment(accKey types.PrivateKey) PriceTablePaymentFunc
PreparePriceTableAccountPayment prepare a payment function to pay for a price table from the given host using the provided revision.
NOTE: This is the preferred way of paying for a price table since it is faster and doesn't require locking a contract.
func PreparePriceTableContractPayment ¶
func PreparePriceTableContractPayment(rev *types.FileContractRevision, refundAccID rhpv3.Account, renterKey types.PrivateKey) PriceTablePaymentFunc
PreparePriceTableContractPayment prepare a payment function to pay for a price table from the given host using the provided revision.
NOTE: This way of paying for a price table should only be used if payment by EA is not possible or if we already need a contract revision anyway. e.g. funding an EA.