Documentation ¶
Overview ¶
Package ant provides an abstraction for the functionality of 'ants' in the antfarm. Ants are Sia clients that have a myriad of user stories programmed as their behavior and report their successfullness at each user store.
Index ¶
- func MerkleRoot(r io.Reader) (h crypto.Hash, err error)
- func NameGeneric(i int) string
- func NameHost(i int) string
- func NameMiner(i int) string
- func NameRenter(i int) string
- func SprintJSON(v interface{}) (string, error)
- type Ant
- func (a *Ant) BlockHeight() types.BlockHeight
- func (a *Ant) Close() error
- func (a *Ant) HasRenterTypeJob() bool
- func (a *Ant) NewClient() (*client.Client, error)
- func (a *Ant) PrintDebugInfo(contractInfo, hostInfo, renterInfo bool) error
- func (a *Ant) StartJob(antsSyncWG *sync.WaitGroup, job string, args ...interface{}) error
- func (a *Ant) StartSiad(siadPath string) error
- func (a *Ant) UpdateSiad(siadPath string) error
- func (a *Ant) WaitConfirmedSiacoinBalance(cmpOp BalanceComparisonOperator, value types.Currency, timeout time.Duration) error
- func (a *Ant) WaitForBlockHeight(blockHeight types.BlockHeight, timeout, frequency time.Duration) error
- func (a *Ant) WaitForContractsToRenew(contractsCount int, timeout time.Duration) error
- func (a *Ant) WaitForRenterWorkersCooldown(timeout time.Duration) error
- func (a *Ant) WalletAddress() (*types.UnlockHash, error)
- type AntConfig
- type BalanceComparisonOperator
- type JobRunner
- type RenterFile
- type RenterJob
- type SiadConfig
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MerkleRoot ¶
MerkleRoot calculates merkle root of the file given in reader
func NameGeneric ¶ added in v1.1.0
NameGeneric returns standardized ant name of generic ant type by the given ant index.
func NameHost ¶ added in v1.1.0
NameHost returns standardized ant name of host ant type by the given ant index.
func NameMiner ¶ added in v1.1.0
NameMiner returns standardized ant name of miner ant type by the given ant index.
func NameRenter ¶ added in v1.1.0
NameRenter returns standardized ant name of renter ant type by the given ant index.
func SprintJSON ¶ added in v1.0.2
SprintJSON is a wrapper for json.MarshalIndent
Types ¶
type Ant ¶
type Ant struct { APIAddr string RPCAddr string Config AntConfig Jr *JobRunner // A variable to track which blocks + heights the sync detector has seen // for this ant. The map will just keep growing, but it shouldn't take up a // prohibitive amount of space. SeenBlocks map[types.BlockHeight]types.BlockID `json:"-"` // contains filtered or unexported fields }
An Ant is a Sia Client programmed with network user stories. It executes these user stories and reports on their successfulness.
func (*Ant) BlockHeight ¶
func (a *Ant) BlockHeight() types.BlockHeight
BlockHeight returns the highest block height seen by the ant.
func (*Ant) HasRenterTypeJob ¶
HasRenterTypeJob returns true if the ant has renter type of job (renter or autoRenter)
func (*Ant) PrintDebugInfo ¶ added in v1.1.0
PrintDebugInfo prints out helpful debug information, arguments define what is printed.
func (*Ant) StartJob ¶
StartJob starts the job indicated by `job` after an ant has been initialized. Arguments are passed to the job using args.
func (*Ant) StartSiad ¶ added in v1.1.0
StartSiad starts ant using the given siad binary on the previously closed ant.
func (*Ant) UpdateSiad ¶ added in v1.0.2
UpdateSiad updates ant to use the given siad binary.
func (*Ant) WaitConfirmedSiacoinBalance ¶ added in v1.1.0
func (a *Ant) WaitConfirmedSiacoinBalance(cmpOp BalanceComparisonOperator, value types.Currency, timeout time.Duration) error
WaitConfirmedSiacoinBalance waits until ant wallet confirmed Siacoins meet comparison condition.
func (*Ant) WaitForBlockHeight ¶ added in v1.1.0
func (a *Ant) WaitForBlockHeight(blockHeight types.BlockHeight, timeout, frequency time.Duration) error
WaitForBlockHeight blocks until the ant reaches the given block height or the timeout is reached.
func (*Ant) WaitForContractsToRenew ¶ added in v1.1.0
WaitForContractsToRenew blocks until renter contracts are renewed.
func (*Ant) WaitForRenterWorkersCooldown ¶ added in v1.1.0
WaitForRenterWorkersCooldown blocks until renter workers price tables are updated and none of renter workers are on cooldown.
func (*Ant) WalletAddress ¶
func (a *Ant) WalletAddress() (*types.UnlockHash, error)
WalletAddress returns a wallet address that this ant can receive coins on.
type AntConfig ¶
type AntConfig struct { SiadConfig Name string `json:",omitempty"` Jobs []string DesiredCurrency uint64 InitialWalletSeed string }
AntConfig represents a configuration object passed to New(), used to configure a newly created Sia Ant.
type BalanceComparisonOperator ¶ added in v1.1.0
type BalanceComparisonOperator string
BalanceComparisonOperator defines type for comparison operators enum
const ( BalanceLess BalanceComparisonOperator = "less then" BalanceLessOrEqual BalanceComparisonOperator = "less then or equal" BalanceEquals BalanceComparisonOperator = "equal" BalanceGreaterOrEqual BalanceComparisonOperator = "greater then or equal" BalanceGreater BalanceComparisonOperator = "greater then" )
BalanceComparisonOperator constants define values for balance comparison operators enum
type JobRunner ¶
type JobRunner struct { StaticWalletSeed string StaticTG threadgroup.ThreadGroup // contains filtered or unexported fields }
A JobRunner is used to start up jobs on the running Sia node.
func (*JobRunner) NewRenterJob ¶
NewRenterJob returns new renter job
func (*JobRunner) Stop ¶
Stop signals all running jobs to stop and blocks until the jobs have finished stopping.
func (*JobRunner) WaitForRenterUploadReady ¶
WaitForRenterUploadReady waits for renter upload ready with default timeout, data pieces and parity pieces if the ant has renter job. If the ant doesn't have renter job, it returns an error.
type RenterFile ¶
RenterFile stores the location and checksum of a file active on the renter.
type RenterJob ¶
type RenterJob struct { Files []RenterFile // contains filtered or unexported fields }
RenterJob contains statefulness that is used to drive the renter. Most importantly, it contains a list of files that the renter is currently uploading to the network.
type SiadConfig ¶
type SiadConfig struct { APIAddr string APIPassword string DataDir string HostAddr string RPCAddr string SiadPath string SiaMuxAddr string SiaMuxWsAddr string AllowHostLocalNetAddress bool RenterDisableIPViolationCheck bool }
SiadConfig contains the necessary config information to create a new siad instance