Documentation ¶
Index ¶
- type ChainManager
- type PaymentSession
- func (ps *PaymentSession) AccountBalance(account rhpv3.Account) (types.Currency, error)
- func (ps *PaymentSession) AppendSector(sector *[rhpv2.SectorSize]byte, revision *rhpv2.ContractRevision, ...) error
- func (ps *PaymentSession) FundAccount(account rhpv3.Account, amount types.Currency) (types.Currency, error)
- func (ps *PaymentSession) LatestRevision(contractID types.FileContractID) (types.FileContractRevision, error)
- func (ps *PaymentSession) ReadSector(root types.Hash256, offset, length uint64, budget types.Currency) ([]byte, error)
- func (ps *PaymentSession) RegisterPriceTable() (rhpv3.HostPriceTable, error)
- func (ps *PaymentSession) StoreSector(sector *[rhpv2.SectorSize]byte, duration uint64, budget types.Currency) error
- type Session
- func (s *Session) Close() error
- func (s *Session) RenewContract(revision *rhpv2.ContractRevision, hostAddr types.Address, ...) (rhpv2.ContractRevision, []types.Transaction, error)
- func (s *Session) ScanPriceTable() (rhpv3.HostPriceTable, error)
- func (s *Session) WithAccountPayment(account rhpv3.Account, privateKey types.PrivateKey) *PaymentSession
- func (s *Session) WithContractPayment(revision *rhpv2.ContractRevision, renterKey types.PrivateKey, ...) *PaymentSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainManager ¶
A ChainManager is used to get the current consensus state
type PaymentSession ¶
type PaymentSession struct { *Session // contains filtered or unexported fields }
A PaymentSession is an RHP3 session with the host that supports payments either from a contract or an ephemeral account
func (*PaymentSession) AccountBalance ¶
AccountBalance retrieves the balance of the given account
func (*PaymentSession) AppendSector ¶
func (ps *PaymentSession) AppendSector(sector *[rhpv2.SectorSize]byte, revision *rhpv2.ContractRevision, renterKey types.PrivateKey, budget types.Currency) error
AppendSector appends a sector to the contract
func (*PaymentSession) FundAccount ¶
func (ps *PaymentSession) FundAccount(account rhpv3.Account, amount types.Currency) (types.Currency, error)
FundAccount funds the account with the given amount
func (*PaymentSession) LatestRevision ¶
func (ps *PaymentSession) LatestRevision(contractID types.FileContractID) (types.FileContractRevision, error)
LatestRevision retrieves the latest revision of the given contract
func (*PaymentSession) ReadSector ¶
func (ps *PaymentSession) ReadSector(root types.Hash256, offset, length uint64, budget types.Currency) ([]byte, error)
ReadSector downloads a sector from the host.
func (*PaymentSession) RegisterPriceTable ¶
func (ps *PaymentSession) RegisterPriceTable() (rhpv3.HostPriceTable, error)
RegisterPriceTable registers the price table with the host
func (*PaymentSession) StoreSector ¶
func (ps *PaymentSession) StoreSector(sector *[rhpv2.SectorSize]byte, duration uint64, budget types.Currency) error
StoreSector stores the given sector for the given duration
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
A Session is an RHP3 session with the host
func NewSession ¶
func NewSession(ctx context.Context, hostKey types.PublicKey, hostAddr string, cm ChainManager, w *wallet.SingleAddressWallet) (*Session, error)
NewSession creates a new session with a host
func (*Session) RenewContract ¶
func (s *Session) RenewContract(revision *rhpv2.ContractRevision, hostAddr types.Address, renterKey types.PrivateKey, renterPayout, newCollateral types.Currency, endHeight uint64) (rhpv2.ContractRevision, []types.Transaction, error)
RenewContract renews an existing contract with the host
func (*Session) ScanPriceTable ¶
func (s *Session) ScanPriceTable() (rhpv3.HostPriceTable, error)
ScanPriceTable retrieves the host's current price table
func (*Session) WithAccountPayment ¶
func (s *Session) WithAccountPayment(account rhpv3.Account, privateKey types.PrivateKey) *PaymentSession
WithAccountPayment creates a new payment session for an account
func (*Session) WithContractPayment ¶
func (s *Session) WithContractPayment(revision *rhpv2.ContractRevision, renterKey types.PrivateKey, refundAccount rhpv3.Account) *PaymentSession
WithContractPayment creates a new payment session for a contract