Documentation ¶
Index ¶
- func IsRevisionMismatch(err error) bool
- type ContractParams
- type ContractSet
- func (cs *ContractSet) Acquire(id types.FileContractID) (*SafeContract, bool)
- func (cs *ContractSet) Close() error
- func (cs *ContractSet) ConvertV130Contract(c V130Contract, cr V130CachedRevision) error
- func (cs *ContractSet) Delete(c *SafeContract)
- func (cs *ContractSet) FormContract(params ContractParams, txnBuilder transactionBuilder, tpool transactionPool, ...) (rc modules.RenterContract, err error)
- func (cs *ContractSet) IDs() []types.FileContractID
- func (cs *ContractSet) Len() int
- func (cs *ContractSet) NewDownloader(host modules.HostDBEntry, id types.FileContractID, hdb hostDB, ...) (_ *Downloader, err error)
- func (cs *ContractSet) NewEditor(host modules.HostDBEntry, id types.FileContractID, ...) (_ *Editor, err error)
- func (cs *ContractSet) RateLimits() (readBPS int64, writeBPS int64, packetSize uint64)
- func (cs *ContractSet) Renew(oldContract *SafeContract, params ContractParams, ...) (rc modules.RenterContract, err error)
- func (cs *ContractSet) Return(c *SafeContract)
- func (cs *ContractSet) SetRateLimits(readBPS int64, writeBPS int64, packetSize uint64)
- func (cs *ContractSet) View(id types.FileContractID) (modules.RenterContract, bool)
- func (cs *ContractSet) ViewAll() []modules.RenterContract
- type Downloader
- type Editor
- type MerkleRootSet
- type SafeContract
- type V130CachedRevision
- type V130Contract
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRevisionMismatch ¶
IsRevisionMismatch returns true if err was caused by the host reporting a different revision number than expected.
Types ¶
type ContractParams ¶
type ContractParams struct { Host modules.HostDBEntry Funding types.Currency StartHeight types.BlockHeight EndHeight types.BlockHeight RefundAddress types.UnlockHash }
ContractParams are supplied as an argument to FormContract.
type ContractSet ¶
type ContractSet struct {
// contains filtered or unexported fields
}
A ContractSet provides safe concurrent access to a set of contracts. Its purpose is to serialize modifications to individual contracts, as well as to provide operations on the set as a whole.
func NewContractSet ¶
func NewContractSet(dir string, deps modules.Dependencies) (*ContractSet, error)
NewContractSet returns a ContractSet storing its contracts in the specified dir.
func (*ContractSet) Acquire ¶
func (cs *ContractSet) Acquire(id types.FileContractID) (*SafeContract, bool)
Acquire looks up the contract for the specified host key and locks it before returning it. If the contract is not present in the set, Acquire returns false and a zero-valued RenterContract.
func (*ContractSet) Close ¶
func (cs *ContractSet) Close() error
Close closes all contracts in a contract set, this means rendering it unusable for I/O
func (*ContractSet) ConvertV130Contract ¶
func (cs *ContractSet) ConvertV130Contract(c V130Contract, cr V130CachedRevision) error
ConvertV130Contract creates a contract file for a v130 contract.
func (*ContractSet) Delete ¶
func (cs *ContractSet) Delete(c *SafeContract)
Delete removes a contract from the set. The contract must have been previously acquired by Acquire. If the contract is not present in the set, Delete is a no-op.
func (*ContractSet) FormContract ¶
func (cs *ContractSet) FormContract(params ContractParams, txnBuilder transactionBuilder, tpool transactionPool, hdb hostDB, cancel <-chan struct{}) (rc modules.RenterContract, err error)
FormContract forms a contract with a host and submits the contract transaction to tpool. The contract is added to the ContractSet and its metadata is returned.
func (*ContractSet) IDs ¶
func (cs *ContractSet) IDs() []types.FileContractID
IDs returns the fcid of each contract with in the set. The contracts are not locked.
func (*ContractSet) Len ¶
func (cs *ContractSet) Len() int
Len returns the number of contracts in the set.
func (*ContractSet) NewDownloader ¶
func (cs *ContractSet) NewDownloader(host modules.HostDBEntry, id types.FileContractID, hdb hostDB, cancel <-chan struct{}) (_ *Downloader, err error)
NewDownloader initiates the download request loop with a host, and returns a Downloader.
func (*ContractSet) NewEditor ¶
func (cs *ContractSet) NewEditor(host modules.HostDBEntry, id types.FileContractID, currentHeight types.BlockHeight, hdb hostDB, cancel <-chan struct{}) (_ *Editor, err error)
NewEditor initiates the contract revision process with a host, and returns an Editor.
func (*ContractSet) RateLimits ¶
func (cs *ContractSet) RateLimits() (readBPS int64, writeBPS int64, packetSize uint64)
RateLimits sets the bandwidth limits for connections created by the contractSet.
func (*ContractSet) Renew ¶
func (cs *ContractSet) Renew(oldContract *SafeContract, params ContractParams, txnBuilder transactionBuilder, tpool transactionPool, hdb hostDB, cancel <-chan struct{}) (rc modules.RenterContract, err error)
Renew negotiates a new contract for data already stored with a host, and submits the new contract transaction to tpool. The new contract is added to the ContractSet and its metadata is returned.
func (*ContractSet) Return ¶
func (cs *ContractSet) Return(c *SafeContract)
Return returns a locked contract to the set and unlocks it. The contract must have been previously acquired by Acquire. If the contract is not present in the set, Return panics.
func (*ContractSet) SetRateLimits ¶
func (cs *ContractSet) SetRateLimits(readBPS int64, writeBPS int64, packetSize uint64)
SetRateLimits sets the bandwidth limits for connections created by the contractSet.
func (*ContractSet) View ¶
func (cs *ContractSet) View(id types.FileContractID) (modules.RenterContract, bool)
View returns a copy of the contract with the specified host key. The contracts is not locked. Certain fields, including the MerkleRoots, are set to nil for safety reasons. If the contract is not present in the set, View returns false and a zero-valued RenterContract.
func (*ContractSet) ViewAll ¶
func (cs *ContractSet) ViewAll() []modules.RenterContract
ViewAll returns the metadata of each contract in the set. The contracts are not locked.
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
A Downloader retrieves sectors by calling the download RPC on a host. Downloaders are NOT thread- safe; calls to Sector must be serialized.
func (*Downloader) Close ¶
func (hd *Downloader) Close() error
Close cleanly terminates the download loop with the host and closes the connection.
func (*Downloader) Sector ¶
func (hd *Downloader) Sector(root crypto.Hash) (_ modules.RenterContract, _ []byte, err error)
Sector retrieves the sector with the specified Merkle root, and revises the underlying contract to pay the host proportionally to the data retrieve.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
A Editor modifies a Contract by calling the revise RPC on a host. It Editors are NOT thread-safe; calls to Upload must happen in serial.
type MerkleRootSet ¶
MerkleRootSet is a set of Merkle roots, and gets encoded more efficiently.
func (MerkleRootSet) MarshalJSON ¶
func (mrs MerkleRootSet) MarshalJSON() ([]byte, error)
MarshalJSON defines a JSON encoding for a MerkleRootSet.
func (*MerkleRootSet) UnmarshalJSON ¶
func (mrs *MerkleRootSet) UnmarshalJSON(b []byte) error
UnmarshalJSON attempts to decode a MerkleRootSet, falling back on the legacy decoding of a []crypto.Hash if that fails.
type SafeContract ¶
type SafeContract struct {
// contains filtered or unexported fields
}
A SafeContract contains the most recent revision transaction negotiated with a host, and the secret key used to sign it.
func (*SafeContract) Metadata ¶
func (c *SafeContract) Metadata() modules.RenterContract
Metadata returns the metadata of a renter contract
func (*SafeContract) UpdateUtility ¶
func (c *SafeContract) UpdateUtility(utility modules.ContractUtility) error
UpdateUtility updates the utility field of a contract.
func (*SafeContract) Utility ¶
func (c *SafeContract) Utility() modules.ContractUtility
Utility returns the contract utility for the contract.
type V130CachedRevision ¶
type V130CachedRevision struct { Revision types.FileContractRevision `json:"revision"` MerkleRoots modules.MerkleRootSet `json:"merkleroots"` }
A V130CachedRevision contains changes that would be applied to a RenterContract if a contract revision succeeded.
type V130Contract ¶
type V130Contract struct { HostPublicKey types.SiaClassicPublicKey `json:"hostpublickey"` ID types.FileContractID `json:"id"` LastRevision types.FileContractRevision `json:"lastrevision"` LastRevisionTxn types.Transaction `json:"lastrevisiontxn"` MerkleRoots MerkleRootSet `json:"merkleroots"` SecretKey crypto.SecretKey `json:"secretkey"` StartHeight types.BlockHeight `json:"startheight"` DownloadSpending types.Currency `json:"downloadspending"` StorageSpending types.Currency `json:"storagespending"` UploadSpending types.Currency `json:"uploadspending"` TotalCost types.Currency `json:"totalcost"` ContractFee types.Currency `json:"contractfee"` TxnFee types.Currency `json:"txnfee"` SiaClassicfundFee types.Currency `json:"siaclassicfundfee"` }
A V130Contract specifies the v130 contract format.
func (*V130Contract) EndHeight ¶
func (c *V130Contract) EndHeight() types.BlockHeight
EndHeight returns the height at which the host is no longer obligated to store contract data.
func (*V130Contract) RenterFunds ¶
func (c *V130Contract) RenterFunds() types.Currency
RenterFunds returns the funds remaining in the contract's Renter payout as of the most recent revision.