rhp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 15 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 PaymentMethod

type PaymentMethod interface {
	Pay(amount types.Currency, height uint64) (rhp3.PaymentMethod, bool)
}

A PaymentMethod facilitates payments to the host using either a contract or an ephemeral account

func AccountPayment

func AccountPayment(account rhp3.Account, privateKey types.PrivateKey) PaymentMethod

AccountPayment creates a new payment method for an account

func ContractPayment

func ContractPayment(revision *rhp2.ContractRevision, renterKey types.PrivateKey, refundAccount rhp3.Account) PaymentMethod

ContractPayment creates a new payment method for a contract

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) (*Session, error)

NewSession creates a new session with a host

func (*Session) AccountBalance

func (s *Session) AccountBalance(account rhp3.Account, payment PaymentMethod) (types.Currency, error)

AccountBalance retrieves the balance of the given account

func (*Session) AppendSector

func (s *Session) AppendSector(sector *[rhp2.SectorSize]byte, revision *rhp2.ContractRevision, renterKey types.PrivateKey, payment PaymentMethod, budget types.Currency) (types.Currency, error)

AppendSector appends a sector to the contract

func (*Session) Close

func (s *Session) Close() error

Close closes the underlying transport

func (*Session) FundAccount

func (s *Session) FundAccount(account rhp3.Account, payment PaymentMethod, amount types.Currency) (types.Currency, error)

FundAccount funds the account with the given amount

func (*Session) ReadSector

func (s *Session) ReadSector(root types.Hash256, offset, length int, payment PaymentMethod, budget types.Currency) ([]byte, types.Currency, error)

ReadSector downloads a sector from the host.

func (*Session) RegisterPriceTable

func (s *Session) RegisterPriceTable(payment PaymentMethod) (rhp3.HostPriceTable, error)

RegisterPriceTable registers the price table with the host

func (*Session) RenewContract

func (s *Session) RenewContract(revision *rhp2.ContractRevision, hostAddr types.Address, renterKey types.PrivateKey, renterPayout, newCollateral types.Currency, endHeight uint64) (rhp2.ContractRevision, []types.Transaction, error)

RenewContract renews an existing contract with the host

func (*Session) Revision

func (s *Session) Revision(contractID types.FileContractID) (types.FileContractRevision, error)

Revision retrieves the latest revision of the contract

func (*Session) ScanPriceTable

func (s *Session) ScanPriceTable() (rhp3.HostPriceTable, error)

ScanPriceTable retrieves the host's current price table

func (*Session) StoreSector

func (s *Session) StoreSector(sector *[rhp2.SectorSize]byte, duration uint64, payment PaymentMethod, budget types.Currency) error

StoreSector stores the given sector for the given duration

type Wallet

type Wallet interface {
	Address() types.Address
	FundTransaction(txn *types.Transaction, amount types.Currency) ([]types.Hash256, func(), error)
	SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error
}

A Wallet funds and signs transactions

Jump to

Keyboard shortcuts

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