Documentation ¶
Index ¶
- Variables
- type AccountManager
- type ChainManager
- type ContractManager
- type FinancialReporter
- type MetricReporter
- type RegistryManager
- type SessionHandler
- func (sh *SessionHandler) Close() error
- func (sh *SessionHandler) HostKey() types.UnlockKey
- func (sh *SessionHandler) LocalAddr() string
- func (sh *SessionHandler) PriceTable() (rhpv3.HostPriceTable, error)
- func (sh *SessionHandler) Serve() error
- func (sh *SessionHandler) WebSocketHandler() http.HandlerFunc
- type SettingsReporter
- type StorageManager
- type TransactionPool
- type Wallet
Constants ¶
This section is empty.
Variables ¶
var ( // ErrContractRevisionLimit is returned when a contract revision would // exceed the maximum revision number. ErrContractRevisionLimit = errors.New("max revision number reached") // ErrContractProofWindowStarted is returned when a contract revision is // attempted after the proof window has started. ErrContractProofWindowStarted = errors.New("proof window has started") // ErrContractExpired is returned when a contract revision is attempted // after the contract has expired. ErrContractExpired = errors.New("contract has expired") // ErrInvalidSectorLength is returned when a sector is not the correct // length. ErrInvalidSectorLength = errors.New("length of sector data must be exactly 4MiB") // ErrTrimOutOfBounds is returned when a trim operation exceeds the total // number of sectors ErrTrimOutOfBounds = errors.New("trim size exceeds number of sectors") // ErrSwapOutOfBounds is returned when one of the swap indices exceeds the // total number of sectors ErrSwapOutOfBounds = errors.New("swap index is out of bounds") // ErrUpdateOutOfBounds is returned when the update index exceeds the total // number of sectors ErrUpdateOutOfBounds = errors.New("update index is out of bounds") // ErrOffsetOutOfBounds is returned when the offset exceeds and length // exceed the sector size. ErrOffsetOutOfBounds = errors.New("update section is out of bounds") // ErrUpdateProofSize is returned when a proof is requested for an update // operation that is not a multiple of 64 bytes. ErrUpdateProofSize = errors.New("update section is not a multiple of the segment size") )
var ( // ErrTxnMissingContract is returned if the transaction set does not contain // any transactions or if the transaction does not contain exactly one // contract. ErrTxnMissingContract = errors.New("transaction set does not contain a file contract") // ErrHostInternalError is returned if the host encountered an error during // an RPC that doesn't need to be broadcast to the renter (e.g. insufficient // funds). ErrHostInternalError = errors.New("internal error") // ErrInvalidRenterSignature is returned when a contract's renter signature // is invalid. ErrInvalidRenterSignature = errors.New("invalid renter signature") // ErrNotAcceptingContracts is returned when the host is not accepting // contracts. ErrNotAcceptingContracts = errors.New("host is not accepting contracts") )
var ( // ErrContractRequired is returned when a contract is required to execute a // program but is not provided ErrContractRequired = errors.New("contract required") )
var ( // ErrNoPriceTable is returned if a price table is requested but the UID // does not exist or has expired. ErrNoPriceTable = errors.New("no price table found") )
Functions ¶
This section is empty.
Types ¶
type AccountManager ¶
type AccountManager interface { Balance(accountID rhpv3.Account) (types.Currency, error) Credit(accountID rhpv3.Account, amount types.Currency, expiration time.Time, refund bool) (balance types.Currency, err error) Budget(accountID rhpv3.Account, amount types.Currency) (*accounts.Budget, error) }
An AccountManager manages deposits and withdrawals for accounts.
type ChainManager ¶
A ChainManager provides access to the current state of the blockchain.
type ContractManager ¶
type ContractManager interface { // Contract returns the last revision of the contract with the given ID. Contract(id types.FileContractID) (contracts.Contract, error) // Lock locks the contract with the given ID. Will wait for the given // duration before giving up. Unlock must be called to unlock the // contract. Lock(ctx context.Context, id types.FileContractID) (contracts.SignedRevision, error) // Unlock unlocks the contract with the given ID. Unlock(id types.FileContractID) // AddContract adds a new contract to the manager. AddContract(revision contracts.SignedRevision, formationSet []types.Transaction, lockedCollateral types.Currency, initialUsage contracts.Usage) error // RenewContract renews an existing contract. RenewContract(renewal contracts.SignedRevision, existing contracts.SignedRevision, formationSet []types.Transaction, lockedCollateral types.Currency, clearingUsage, renewalUsage contracts.Usage) error // ReviseContract atomically revises a contract and its sector roots ReviseContract(contractID types.FileContractID) (*contracts.ContractUpdater, error) // SectorRoots returns the sector roots of the contract with the given ID. SectorRoots(id types.FileContractID, limit, offset uint64) ([]types.Hash256, error) }
A ContractManager manages the set of contracts that the host is currently storing data for
type FinancialReporter ¶
type FinancialReporter interface {
Add(financials.Record) error
}
A FinancialReporter records financial transactions on the host.
type MetricReporter ¶
MetricReporter records metrics from the host
type RegistryManager ¶
type RegistryManager interface { Get(key rhpv3.RegistryKey) (rhpv3.RegistryValue, error) Put(value rhpv3.RegistryEntry, expirationHeight uint64) (rhpv3.RegistryValue, error) Entries() (count uint64, max uint64, err error) }
A RegistryManager manages registry entries stored in a RegistryStore.
type SessionHandler ¶
type SessionHandler struct {
// contains filtered or unexported fields
}
A SessionHandler handles the host side of the renter-host protocol and manages renter sessions
func NewSessionHandler ¶
func NewSessionHandler(l net.Listener, hostKey types.PrivateKey, chain ChainManager, tpool TransactionPool, wallet Wallet, accounts AccountManager, contracts ContractManager, registry RegistryManager, storage StorageManager, settings SettingsReporter, monitor rhp.DataMonitor, metrics MetricReporter, log *zap.Logger) (*SessionHandler, error)
NewSessionHandler creates a new SessionHandler
func (*SessionHandler) Close ¶
func (sh *SessionHandler) Close() error
Close closes the session handler and stops accepting new connections.
func (*SessionHandler) HostKey ¶
func (sh *SessionHandler) HostKey() types.UnlockKey
HostKey returns the host's ed25519 public key
func (*SessionHandler) LocalAddr ¶
func (sh *SessionHandler) LocalAddr() string
LocalAddr returns the address the host is listening on.
func (*SessionHandler) PriceTable ¶
func (sh *SessionHandler) PriceTable() (rhpv3.HostPriceTable, error)
PriceTable returns the session handler's current price table.
func (*SessionHandler) Serve ¶
func (sh *SessionHandler) Serve() error
Serve starts the host RPC server.
func (*SessionHandler) WebSocketHandler ¶
func (sh *SessionHandler) WebSocketHandler() http.HandlerFunc
WebSocketHandler returns an http.Handler that upgrades the connection to a WebSocket and then passes the connection to the RHP3 host transport.
type SettingsReporter ¶
type SettingsReporter interface { Settings() settings.Settings BandwidthLimiters() (ingress, egress *rate.Limiter) }
A SettingsReporter reports the host's current configuration.
type StorageManager ¶
type StorageManager interface { Usage() (used, total uint64, _ error) // LockSector locks the sector with the given root. If the sector does not // exist, an error is returned. Release must be called when the sector is no // longer needed. LockSector(root types.Hash256) (func() error, error) // Write writes a sector to persistent storage. release should only be // called after the contract roots have been committed to prevent the // sector from being deleted. Write(root types.Hash256, data *[rhpv2.SectorSize]byte) (release func() error, _ error) // Read reads the sector with the given root from the manager. Read(root types.Hash256) (*[rhpv2.SectorSize]byte, error) // Sync syncs the data files of changed volumes. Sync() error // AddTemporarySectors adds the given sectors to the storage manager. // as temporary sectors. Temporary sectors are short-lived sectors not // associated with a contract. AddTemporarySectors([]storage.TempSector) error }
A StorageManager manages the storage of sectors on disk.
type TransactionPool ¶
type TransactionPool interface { AcceptTransactionSet([]types.Transaction) error RecommendedFee() types.Currency }
A TransactionPool broadcasts transactions to the network.
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 manages funds and signs transactions