Documentation ¶
Index ¶
Constants ¶
const (
// Version is the current version of the RHP2 protocol.
Version = "1.6.0"
)
Variables ¶
var ( // ErrNoContractLocked is returned when a contract revision is attempted // without a contract being locked. ErrNoContractLocked = errors.New("no contract locked") // 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") )
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("host internal error") // ErrInvalidRenterSignature is returned when a contract's renter signature // is invalid. ErrInvalidRenterSignature = errors.New("invalid renter signature") // ErrContractAlreadyLocked is returned when a renter tries to lock // a contract before unlocking the previous one. ErrContractAlreadyLocked = errors.New("contract already locked") // ErrNotAcceptingContracts is returned when the host is not accepting // contracts. ErrNotAcceptingContracts = errors.New("host is not accepting contracts") )
Functions ¶
This section is empty.
Types ¶
type ChainManager ¶
A ChainManager provides access to the current state of the blockchain.
type ContractManager ¶
type ContractManager interface { // 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) ([]types.Hash256, error) }
A ContractManager manages the set of contracts that the host is currently storing data for
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, rhp3Addr string, cm ChainManager, tpool TransactionPool, wallet Wallet, contracts ContractManager, settings SettingsReporter, storage StorageManager, monitor rhp.DataMonitor, sessions SessionReporter, log *zap.Logger) (*SessionHandler, error)
NewSessionHandler creates a new RHP2 SessionHandler
func (*SessionHandler) Close ¶
func (sh *SessionHandler) Close() error
Close closes the listener and stops accepting new connections
func (*SessionHandler) LocalAddr ¶
func (sh *SessionHandler) LocalAddr() string
LocalAddr returns the listener's listen address
func (*SessionHandler) Serve ¶
func (sh *SessionHandler) Serve() error
Serve starts listening for new connections and blocks until closed
func (*SessionHandler) Settings ¶
func (sh *SessionHandler) Settings() (rhp2.HostSettings, error)
Settings returns the host's current settings
type SessionReporter ¶ added in v0.2.0
type SessionReporter interface { StartSession(conn *rhp.Conn, proto string, version int) (sessionID rhp.UID, end func()) StartRPC(sessionID rhp.UID, rpc types.Specifier) (rpcID rhp.UID, end func(contracts.Usage, error)) }
SessionReporter reports session metrics
type SettingsReporter ¶
type SettingsReporter interface { DiscoveredRHP2Address() string 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) // 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 *[rhp2.SectorSize]byte) (release func() error, _ error) // Read reads the sector with the given root from the manager. Read(root types.Hash256) (*[rhp2.SectorSize]byte, error) // Sync syncs the data files of changed volumes. Sync() 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