Documentation ¶
Index ¶
- func IsRevisionMismatch(err error) bool
- type ContractSet
- func (cs *ContractSet) Acquire(id types.FileContractID) (*FileContract, bool)
- func (cs *ContractSet) ByRenter(rpk types.PublicKey) []modules.RenterContract
- func (cs *ContractSet) Delete(c *FileContract)
- func (cs *ContractSet) DeleteOldContracts(height uint64)
- func (cs *ContractSet) Erase(fcid types.FileContractID)
- func (cs *ContractSet) IDs(rpk types.PublicKey) []types.FileContractID
- func (cs *ContractSet) InsertContract(revisionTxn types.Transaction, startHeight uint64, ...) (modules.RenterContract, error)
- func (cs *ContractSet) Len() int
- func (cs *ContractSet) OldByRenter(rpk types.PublicKey) []modules.RenterContract
- func (cs *ContractSet) OldContract(id types.FileContractID) (modules.RenterContract, bool)
- func (cs *ContractSet) OldContracts() []modules.RenterContract
- func (cs *ContractSet) RenterByContractID(fcid types.FileContractID) (rpk types.PublicKey, err error)
- func (cs *ContractSet) ReplaceOldContract(fcid types.FileContractID, c *FileContract)
- func (cs *ContractSet) RetireContract(id types.FileContractID)
- func (cs *ContractSet) Return(c *FileContract)
- func (cs *ContractSet) UnlockPayout(id types.FileContractID)
- func (cs *ContractSet) UpdateContract(rev types.FileContractRevision, sigs []types.TransactionSignature, ...) error
- func (cs *ContractSet) View(id types.FileContractID) (modules.RenterContract, bool)
- func (cs *ContractSet) ViewAll() []modules.RenterContract
- type FileContract
- func (c *FileContract) Clear(txn types.Transaction) error
- func (c *FileContract) DecodeFrom(d *types.Decoder)
- func (c *FileContract) EncodeTo(e *types.Encoder)
- func (c *FileContract) LastRevision() types.FileContractRevision
- func (c *FileContract) Metadata() modules.RenterContract
- func (c *FileContract) UpdateUtility(utility modules.ContractUtility) error
- func (c *FileContract) Utility() modules.ContractUtility
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 ContractSet ¶
type ContractSet struct {
// contains filtered or unexported fields
}
A ContractSet provides 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 ¶
NewContractSet returns a ContractSet storing its contracts in the specified database.
func (*ContractSet) Acquire ¶
func (cs *ContractSet) Acquire(id types.FileContractID) (*FileContract, 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) ByRenter ¶
func (cs *ContractSet) ByRenter(rpk types.PublicKey) []modules.RenterContract
ByRenter works the same as ViewAll but filters the contracts by the renter.
func (*ContractSet) Delete ¶
func (cs *ContractSet) Delete(c *FileContract)
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) DeleteOldContracts ¶
func (cs *ContractSet) DeleteOldContracts(height uint64)
DeleteOldContracts deletes old contracts from both the set and the database.
func (*ContractSet) Erase ¶
func (cs *ContractSet) Erase(fcid types.FileContractID)
Erase removes a contract from the database.
func (*ContractSet) IDs ¶
func (cs *ContractSet) IDs(rpk types.PublicKey) []types.FileContractID
IDs returns the fcid of each contract with in the set. The contracts are not locked.
func (*ContractSet) InsertContract ¶
func (cs *ContractSet) InsertContract(revisionTxn types.Transaction, startHeight uint64, totalCost, contractFee, txnFee, siafundFee types.Currency, rpk types.PublicKey, imported bool) (modules.RenterContract, error)
InsertContract prepares a new contract header and adds it to the set.
func (*ContractSet) Len ¶
func (cs *ContractSet) Len() int
Len returns the number of contracts in the set.
func (*ContractSet) OldByRenter ¶
func (cs *ContractSet) OldByRenter(rpk types.PublicKey) []modules.RenterContract
OldByRenter works the same as OldContracts but filters the contracts by the renter.
func (*ContractSet) OldContract ¶
func (cs *ContractSet) OldContract(id types.FileContractID) (modules.RenterContract, bool)
OldContract returns the metadata of the specified old contract.
func (*ContractSet) OldContracts ¶
func (cs *ContractSet) OldContracts() []modules.RenterContract
OldContracts returns the metadata of each old contract.
func (*ContractSet) RenterByContractID ¶ added in v0.9.0
func (cs *ContractSet) RenterByContractID(fcid types.FileContractID) (rpk types.PublicKey, err error)
RenterByContractID tries to find a renter by the provided contract ID.
func (*ContractSet) ReplaceOldContract ¶
func (cs *ContractSet) ReplaceOldContract(fcid types.FileContractID, c *FileContract)
ReplaceOldContract replaces the duplicated old contract.
func (*ContractSet) RetireContract ¶
func (cs *ContractSet) RetireContract(id types.FileContractID)
RetireContract adds the contract to the old contracts map.
func (*ContractSet) Return ¶
func (cs *ContractSet) Return(c *FileContract)
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) UnlockPayout ¶ added in v0.8.0
func (cs *ContractSet) UnlockPayout(id types.FileContractID)
UnlockPayout sets the 'Unlocked' status of a contract to true.
func (*ContractSet) UpdateContract ¶
func (cs *ContractSet) UpdateContract(rev types.FileContractRevision, sigs []types.TransactionSignature, uploads, downloads, fundAccount types.Currency) error
UpdateContract updates the contract with the new revision.
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 contract is not locked. 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 FileContract ¶
type FileContract struct {
// contains filtered or unexported fields
}
A FileContract contains the most recent revision transaction negotiated with a host, and the secret key used to sign it.
func (*FileContract) Clear ¶
func (c *FileContract) Clear(txn types.Transaction) error
Clear commits the changes we made to the revision when clearing a contract.
func (*FileContract) DecodeFrom ¶
func (c *FileContract) DecodeFrom(d *types.Decoder)
DecodeFrom implements types.DecoderFrom.
func (*FileContract) EncodeTo ¶
func (c *FileContract) EncodeTo(e *types.Encoder)
EncodeTo implements types.EncoderTo.
func (*FileContract) LastRevision ¶
func (c *FileContract) LastRevision() types.FileContractRevision
LastRevision returns the most recent revision.
func (*FileContract) Metadata ¶
func (c *FileContract) Metadata() modules.RenterContract
Metadata returns the metadata of a renter contract.
func (*FileContract) UpdateUtility ¶
func (c *FileContract) UpdateUtility(utility modules.ContractUtility) error
UpdateUtility updates the utility field of a contract.
func (*FileContract) Utility ¶
func (c *FileContract) Utility() modules.ContractUtility
Utility returns the contract utility for the contract.