Documentation ¶
Overview ¶
The sia package is made up of multiple components, each implemented using an interface. The list:
Host HostDB Miner Network (Peer Manager) Renter Wallet
Index ¶
- Constants
- type Config
- type Core
- func (c *Core) AcceptBlock(b consensus.Block) error
- func (c *Core) AcceptTransaction(t consensus.Transaction) error
- func (c *Core) AddPeer(addr network.Address) error
- func (c *Core) Address() network.Address
- func (c *Core) AddressBook() []network.Address
- func (c *Core) AnnounceHost(freezeVolume consensus.Currency, freezeUnlockHeight consensus.BlockHeight) (err error)
- func (c *Core) BlockAtHeight(height consensus.BlockHeight) (consensus.Block, error)
- func (c *Core) BlockChan() chan consensus.Block
- func (c *Core) BlockFromID(bid consensus.BlockID) (consensus.Block, error)
- func (c *Core) CatchUp(peer network.Address)
- func (c *Core) Close()
- func (c *Core) CoinAddress() (address consensus.CoinAddress, err error)
- func (c *Core) DeepStateInfo() DeepStateInfo
- func (c *Core) Height() consensus.BlockHeight
- func (c *Core) HostInfo() (components.HostInfo, error)
- func (c *Core) MinerInfo() (components.MinerInfo, error)
- func (c *Core) Output(id consensus.OutputID) (output consensus.Output, err error)
- func (c *Core) RandomPeer() network.Address
- func (c *Core) RemovePeer(addr network.Address) error
- func (c *Core) RenameFile(currentName, newName string) error
- func (c *Core) RentFile(params components.RentFileParameters) error
- func (c *Core) RentInfo() (components.RentInfo, error)
- func (c *Core) RentSmallFile(params components.RentSmallFileParameters) error
- func (c *Core) RenterDownload(nickname, filepath string) error
- func (c *Core) ScanMutexes()
- func (c *Core) SendBlocks(knownBlocks [32]consensus.BlockID) (blocks []consensus.Block, err error)
- func (c *Core) SpendCoins(amount consensus.Currency, dest consensus.CoinAddress) (t consensus.Transaction, err error)
- func (c *Core) StartMining() error
- func (c *Core) StateInfo() StateInfo
- func (c *Core) StopMining() error
- func (c *Core) StorageProofSegmentIndex(contractID consensus.ContractID, windowIndex consensus.BlockHeight) (index uint64, err error)
- func (c *Core) TransactionChan() chan consensus.Transaction
- func (c *Core) TransactionList() []consensus.Transaction
- func (c *Core) UpdateHost(announcement components.HostAnnouncement) error
- func (c *Core) UpdateMiner(threads int) (err error)
- func (c *Core) WalletBalance(full bool) consensus.Currency
- func (c *Core) WalletInfo() (components.WalletInfo, error)
- type DeepStateInfo
- type StateInfo
Constants ¶
const (
MaxCatchUpBlocks = 100
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // The State, which is separate from a componenent as it is not an // interface. There is a single implementation which is considered // acceptible. State *consensus.State // Interface implementations. Host components.Host HostDB components.HostDB Miner components.Miner Renter components.Renter Wallet components.Wallet // Settings available through flags. // // TODO: Most of these should be deprecated as inputs to the core - each // component should manage its own settings. HostDir string WalletFile string ServerAddr string Nobootstrap bool }
The config struct is used when calling CreateCore(), and prevents the input line from being excessively long.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is the struct that serves as the state for siad. It contains a pointer to the state, as things like a wallet, a friend list, etc. Each environment should have its own state.
func CreateCore ¶
createCore creates a server, host, miner, renter and wallet and puts it all in a single environment struct that's used as the state for the main package.
func (*Core) AcceptBlock ¶
AcceptBlock sends the input block down a channel, where it will be dealt with by the Core's listener.
func (*Core) AcceptTransaction ¶
func (c *Core) AcceptTransaction(t consensus.Transaction) error
AcceptTransaction sends the input transaction down a channel, where it will be dealt with by the Core's listener.
func (*Core) Address ¶
Address returns the address of the server. This may be inaccurate if the server was unable to determine its external IP.
func (*Core) AddressBook ¶
AddressBook returns a listing of all known peers.
func (*Core) AnnounceHost ¶
func (*Core) BlockAtHeight ¶
func (*Core) BlockFromID ¶
func (*Core) CatchUp ¶
CatchUp synchronizes with a peer to acquire any missing blocks. The requester sends 32 blocks, starting with the 12 most recent and then progressing exponentially backwards to the genesis block. The receiver uses these blocks to find the most recent block seen by both peers, and then transmits blocks sequentially until the requester is fully synchronized.
func (*Core) Close ¶
func (c *Core) Close()
Close does any finishing maintenence before the environment can be garbage collected. Right now that just means closing the server.
func (*Core) CoinAddress ¶
func (c *Core) CoinAddress() (address consensus.CoinAddress, err error)
CoinAddress returns the CoinAddress which foreign coins should be sent to.
func (*Core) DeepStateInfo ¶
func (c *Core) DeepStateInfo() DeepStateInfo
func (*Core) Height ¶
func (c *Core) Height() consensus.BlockHeight
func (*Core) MinerInfo ¶
func (c *Core) MinerInfo() (components.MinerInfo, error)
MinerInfo calls Info on the miner.
func (*Core) Output ¶
Output returns the output that corresponds with a certain OutputID. It does not lock the mutex, which means it could potentially (but usually doesn't) produce weird or incorrect output.
func (*Core) RandomPeer ¶
RandomPeer provides a random peer from the peer list.
func (*Core) RemovePeer ¶
RemovePeer removes a peer.
func (*Core) RenameFile ¶
func (*Core) RentFile ¶
func (c *Core) RentFile(params components.RentFileParameters) error
func (*Core) RentSmallFile ¶
func (c *Core) RentSmallFile(params components.RentSmallFileParameters) error
func (*Core) RenterDownload ¶
func (*Core) ScanMutexes ¶
func (c *Core) ScanMutexes()
func (*Core) SendBlocks ¶
SendBlocks takes a list of block ids as input, and sends all blocks from
func (*Core) SpendCoins ¶
func (c *Core) SpendCoins(amount consensus.Currency, dest consensus.CoinAddress) (t consensus.Transaction, err error)
SpendCoins creates a transaction sending 'amount' to 'dest', and allocateding 'minerFee' as a miner fee. The transaction is submitted to the miner pool, but is also returned.
func (*Core) StartMining ¶
StartMining calls StartMining on the miner.
func (*Core) StateInfo ¶
StateInfo returns a bunch of useful information about the state, doing read-only accesses. StateInfo does not lock the state mutex, which means that the data could potentially be weird on account of race conditions. Because it's just a read-only call, it will not adversely affect the state. If accurate data is paramount, SafeStateInfo() should be called, though this can adversely affect performance.
func (*Core) StopMining ¶
StopMining calls StopMining on the miner.
func (*Core) StorageProofSegmentIndex ¶
func (c *Core) StorageProofSegmentIndex(contractID consensus.ContractID, windowIndex consensus.BlockHeight) (index uint64, err error)
func (*Core) TransactionChan ¶
func (c *Core) TransactionChan() chan consensus.Transaction
TransactionChan provides a channel to inform the core of new transactions.
func (*Core) TransactionList ¶
func (c *Core) TransactionList() []consensus.Transaction
func (*Core) UpdateHost ¶
func (c *Core) UpdateHost(announcement components.HostAnnouncement) error
TODO: Make a better UpdateHost thing.
func (*Core) UpdateMiner ¶
UpdateMiner needs to be called with the state read-locked. UpdateMiner takes a miner as input and calls `miner.Update()` with all of the recent values from the state.
func (*Core) WalletBalance ¶
WalletBalance counts up the total number of coins that the wallet knows how to spend, according to the State. WalletBalance will ignore all unconfirmed transactions that have been created.
func (*Core) WalletInfo ¶
func (c *Core) WalletInfo() (components.WalletInfo, error)
Returns a []byte that's supposed to be json of some struct.
type DeepStateInfo ¶
type DeepStateInfo struct { StateHash hash.Hash UtxoSet []consensus.Output TransactionList []consensus.Transaction }
Contains in depth information about the state - potentially a lot of information.