sia

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: 9 Imported by: 0

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

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

func CreateCore(config Config) (c *Core, err error)

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

func (c *Core) AcceptBlock(b consensus.Block) error

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

func (c *Core) AddPeer(addr network.Address) error

AddPeer adds a peer.

func (*Core) Address

func (c *Core) Address() network.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

func (c *Core) AddressBook() []network.Address

AddressBook returns a listing of all known peers.

func (*Core) AnnounceHost

func (c *Core) AnnounceHost(freezeVolume consensus.Currency, freezeUnlockHeight consensus.BlockHeight) (err error)

func (*Core) BlockAtHeight

func (c *Core) BlockAtHeight(height consensus.BlockHeight) (consensus.Block, error)

func (*Core) BlockChan

func (c *Core) BlockChan() chan consensus.Block

BlockChan provides a channel to inform the core of new blocks.

func (*Core) BlockFromID

func (c *Core) BlockFromID(bid consensus.BlockID) (consensus.Block, error)

func (*Core) CatchUp

func (c *Core) CatchUp(peer network.Address)

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

func (c *Core) HostInfo() (components.HostInfo, error)

func (*Core) MinerInfo

func (c *Core) MinerInfo() (components.MinerInfo, error)

MinerInfo calls Info on the miner.

func (*Core) Output

func (c *Core) Output(id consensus.OutputID) (output consensus.Output, err error)

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

func (c *Core) RandomPeer() network.Address

RandomPeer provides a random peer from the peer list.

func (*Core) RemovePeer

func (c *Core) RemovePeer(addr network.Address) error

RemovePeer removes a peer.

func (*Core) RenameFile

func (c *Core) RenameFile(currentName, newName string) error

func (*Core) RentFile

func (c *Core) RentFile(params components.RentFileParameters) error

func (*Core) RentInfo

func (c *Core) RentInfo() (components.RentInfo, error)

func (*Core) RentSmallFile

func (c *Core) RentSmallFile(params components.RentSmallFileParameters) error

func (*Core) RenterDownload

func (c *Core) RenterDownload(nickname, filepath string) error

func (*Core) ScanMutexes

func (c *Core) ScanMutexes()

func (*Core) SendBlocks

func (c *Core) SendBlocks(knownBlocks [32]consensus.BlockID) (blocks []consensus.Block, err error)

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

func (c *Core) StartMining() error

StartMining calls StartMining on the miner.

func (*Core) StateInfo

func (c *Core) StateInfo() 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

func (c *Core) StopMining() error

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

func (c *Core) UpdateMiner(threads int) (err error)

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

func (c *Core) WalletBalance(full bool) consensus.Currency

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.

type StateInfo

type StateInfo struct {
	CurrentBlock           consensus.BlockID
	Height                 consensus.BlockHeight
	Target                 consensus.Target
	Depth                  consensus.Target
	EarliestLegalTimestamp consensus.Timestamp
}

Contains basic information about the state, but does not go into depth.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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