rhp

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainManager

type ChainManager interface {
	TipState() consensus.State
}

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

func (ps *PaymentSession) AccountBalance(account rhpv3.Account) (types.Currency, error)

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

func (s *Session) Close() error

Close closes the session

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

Jump to

Keyboard shortcuts

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