host

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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 New

func New(state *consensus.State, wallet components.Wallet) (h *Host, err error)

New returns an initialized Host.

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) HostInfo

func (h *Host) HostInfo() (info components.HostInfo, err error)

func (*Host) NegotiateContract

func (h *Host) NegotiateContract(conn net.Conn) (err error)

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) NumContracts

func (h *Host) NumContracts() int

TODO: Deprecate this function.

func (*Host) RetrieveFile

func (h *Host) RetrieveFile(conn net.Conn) (err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL