Documentation ¶
Index ¶
- Constants
- type ContractEntry
- type Host
- func (h *Host) AnnounceHost(freezeVolume consensus.Currency, freezeUnlockHeight consensus.BlockHeight) (t consensus.Transaction, err error)
- func (h *Host) HostInfo() (info components.HostInfo, err error)
- func (h *Host) NegotiateContract(conn net.Conn) (err error)
- func (h *Host) NumContracts() int
- func (h *Host) RetrieveFile(conn net.Conn) (err error)
- func (h *Host) UpdateHost(update components.HostUpdate) error
Constants ¶
const (
StorageProofReorgDepth = 6 // How many blocks to wait before submitting a storage proof.
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContractEntry ¶
type ContractEntry struct { ID consensus.ContractID Contract consensus.FileContract }
ContractEntry houses a single contract with its id - you cannot derive the id of a contract without having the transaction. Rather than keep the whole transaction, we store only the id.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
func (*Host) AnnounceHost ¶
func (h *Host) AnnounceHost(freezeVolume consensus.Currency, freezeUnlockHeight consensus.BlockHeight) (t consensus.Transaction, err error)
HostAnnounceSelf creates a host announcement transaction, adding information to the arbitrary data and then signing the transaction.
func (*Host) NegotiateContract ¶
NegotiateContract is an RPC that negotiates a file contract. If the negotiation is successful, the file is downloaded and the host begins submitting proofs of storage.
Care is taken not to have any locks in place when network communication is happening, nor while any intensive file operations are happening. For this reason, all of the locking in this function is done manually. Edit with caution, review with caution.
TODO: Split some of this logic into helper functions, which in particular will make mutex management easier.
func (*Host) RetrieveFile ¶
RetrieveFile is an RPC that uploads a specified file to a client.
Mutexes are applied carefully to avoid any disk intensive or network intensive operations. All necessary interaction with the host involves looking up the filepath of the file being requested. This is done all at once.
TODO: Move this function to a different file in the package?
func (*Host) UpdateHost ¶
func (h *Host) UpdateHost(update components.HostUpdate) error
UpdateHost changes the settings of the host to the input settings. SpaceRemaining will be changed accordingly, and will not return an error if space remaining goes negative.