Documentation ¶
Index ¶
- Variables
- func NewServer(e Explorer, cm ChainManager, s Syncer) http.Handler
- type AddressBalanceResponse
- type ChainManager
- type Client
- func (c *Client) AddressBalance(address types.Address) (resp AddressBalanceResponse, err error)
- func (c *Client) AddressEvents(address types.Address, offset, limit uint64) (resp []explorer.Event, err error)
- func (c *Client) AddressSiacoinUTXOs(address types.Address, offset, limit uint64) (resp []explorer.SiacoinOutput, err error)
- func (c *Client) AddressSiafundUTXOs(address types.Address, offset, limit uint64) (resp []explorer.SiafundOutput, err error)
- func (c *Client) BestIndex(height uint64) (resp types.ChainIndex, err error)
- func (c *Client) Block(id types.BlockID) (resp explorer.Block, err error)
- func (c *Client) BlockMetrics() (resp explorer.Metrics, err error)
- func (c *Client) BlockMetricsID(id types.BlockID) (resp explorer.Metrics, err error)
- func (c *Client) ConsensusNetwork() (n *consensus.Network, err error)
- func (c *Client) ConsensusState() (state consensus.State, err error)
- func (c *Client) ConsensusTip() (resp types.ChainIndex, err error)
- func (c *Client) Contract(id types.FileContractID) (resp explorer.ExtendedFileContract, err error)
- func (c *Client) ContractRevisions(id types.FileContractID) (resp []explorer.ExtendedFileContract, err error)
- func (c *Client) Contracts(ids []types.FileContractID) (resp []explorer.ExtendedFileContract, err error)
- func (c *Client) ContractsKey(key types.PublicKey) (resp []explorer.ExtendedFileContract, err error)
- func (c *Client) Host(key types.PublicKey) (resp explorer.Host, err error)
- func (c *Client) HostMetrics() (resp explorer.HostMetrics, err error)
- func (c *Client) OutputSiacoin(id types.SiacoinOutputID) (resp explorer.SiacoinOutput, err error)
- func (c *Client) OutputSiafund(id types.SiafundOutputID) (resp explorer.SiafundOutput, err error)
- func (c *Client) Search(id types.Hash256) (resp explorer.SearchType, err error)
- func (c *Client) State() (resp StateResponse, err error)
- func (c *Client) SyncerBroadcastBlock(b types.Block) (err error)
- func (c *Client) SyncerConnect(addr string) (err error)
- func (c *Client) SyncerPeers() (resp []string, err error)
- func (c *Client) Tip() (resp types.ChainIndex, err error)
- func (c *Client) Transaction(id types.TransactionID) (resp explorer.Transaction, err error)
- func (c *Client) TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error)
- func (c *Client) Transactions(ids []types.TransactionID) (resp []explorer.Transaction, err error)
- func (c *Client) TxpoolBroadcast(txns []types.Transaction, v2txns []types.V2Transaction) (err error)
- func (c *Client) TxpoolFee() (resp types.Currency, err error)
- func (c *Client) TxpoolTransactions() (txns []types.Transaction, v2txns []types.V2Transaction, err error)
- func (c *Client) V2Contract(id types.FileContractID) (resp explorer.V2FileContract, err error)
- func (c *Client) V2ContractRevisions(id types.FileContractID) (resp []explorer.V2FileContract, err error)
- func (c *Client) V2Contracts(ids []types.FileContractID) (resp []explorer.V2FileContract, err error)
- func (c *Client) V2ContractsKey(key types.PublicKey) (resp []explorer.V2FileContract, err error)
- func (c *Client) V2Transaction(id types.TransactionID) (resp explorer.V2Transaction, err error)
- func (c *Client) V2TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error)
- func (c *Client) V2Transactions(ids []types.TransactionID) (resp []explorer.V2Transaction, err error)
- type Explorer
- type GatewayPeer
- type StateResponse
- type Syncer
- type TxpoolBroadcastRequest
- type TxpoolTransactionsResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTransactionNotFound is returned by /transactions/:id when we are // unable to find the transaction with that `id`. ErrTransactionNotFound = errors.New("no transaction found") // ErrSiacoinOutputNotFound is returned by /outputs/siacoin/:id when we // are unable to find the siacoin output with that `id`. ErrSiacoinOutputNotFound = errors.New("no siacoin output found") // ErrSiafundOutputNotFound is returned by /outputs/siafund/:id when we // are unable to find the siafund output with that `id`. ErrSiafundOutputNotFound = errors.New("no siafund output found") // ErrHostNotFound is returned by /pubkey/:key/host when we are unable to // find the host with the pubkey `key`. ErrHostNotFound = errors.New("no host found") // ErrNoSearchResults is returned by /search/:id when we do not find any // elements with that ID. ErrNoSearchResults = errors.New("no search results found") // ErrTooManyIDs is returned by the batch transaction and contract // endpoints when more than maxIDs IDs are specified. ErrTooManyIDs = fmt.Errorf("too many IDs provided (provide less than %d)", maxIDs) )
Functions ¶
Types ¶
type AddressBalanceResponse ¶
type AddressBalanceResponse struct { UnspentSiacoins types.Currency `json:"unspentSiacoins"` ImmatureSiacoins types.Currency `json:"immatureSiacoins"` UnspentSiafunds uint64 `json:"unspentSiafunds"` }
AddressBalanceResponse is the response for /addresses/:address/balance.
type ChainManager ¶
type ChainManager interface { Tip() types.ChainIndex TipState() consensus.State AddBlocks([]types.Block) error RecommendedFee() types.Currency PoolTransactions() []types.Transaction V2PoolTransactions() []types.V2Transaction AddPoolTransactions(txns []types.Transaction) (bool, error) AddV2PoolTransactions(index types.ChainIndex, txns []types.V2Transaction) (bool, error) UnconfirmedParents(txn types.Transaction) []types.Transaction }
A ChainManager manages blockchain and txpool state.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client provides methods for interacting with a explored API server.
func NewClient ¶
NewClient returns a client that communicates with a explored server listening on the specified address.
func (*Client) AddressBalance ¶
func (c *Client) AddressBalance(address types.Address) (resp AddressBalanceResponse, err error)
AddressBalance returns the specified address' balance.
func (*Client) AddressEvents ¶
func (c *Client) AddressEvents(address types.Address, offset, limit uint64) (resp []explorer.Event, err error)
AddressEvents returns the specified address' events.
func (*Client) AddressSiacoinUTXOs ¶
func (c *Client) AddressSiacoinUTXOs(address types.Address, offset, limit uint64) (resp []explorer.SiacoinOutput, err error)
AddressSiacoinUTXOs returns the specified address' unspent outputs.
func (*Client) AddressSiafundUTXOs ¶
func (c *Client) AddressSiafundUTXOs(address types.Address, offset, limit uint64) (resp []explorer.SiafundOutput, err error)
AddressSiafundUTXOs returns the specified address' unspent outputs.
func (*Client) BestIndex ¶
func (c *Client) BestIndex(height uint64) (resp types.ChainIndex, err error)
BestIndex returns the chain index at the specified height.
func (*Client) BlockMetrics ¶
BlockMetrics returns the most recent metrics about the Sia blockchain.
func (*Client) BlockMetricsID ¶
BlockMetricsID returns various metrics about Sia at the given block ID.
func (*Client) ConsensusNetwork ¶
ConsensusNetwork returns the network parameters of the consensus set.
func (*Client) ConsensusState ¶
ConsensusState returns the current state of the consensus set.
func (*Client) ConsensusTip ¶
func (c *Client) ConsensusTip() (resp types.ChainIndex, err error)
ConsensusTip returns the current tip of the chain manager.
func (*Client) Contract ¶
func (c *Client) Contract(id types.FileContractID) (resp explorer.ExtendedFileContract, err error)
Contract returns the file contract with the specified ID.
func (*Client) ContractRevisions ¶
func (c *Client) ContractRevisions(id types.FileContractID) (resp []explorer.ExtendedFileContract, err error)
ContractRevisions returns all the revisions of the contract with the specified ID.
func (*Client) Contracts ¶
func (c *Client) Contracts(ids []types.FileContractID) (resp []explorer.ExtendedFileContract, err error)
Contracts returns the contracts with the specified IDs.
func (*Client) ContractsKey ¶
func (c *Client) ContractsKey(key types.PublicKey) (resp []explorer.ExtendedFileContract, err error)
ContractsKey returns the contracts for a particular ed25519 key.
func (*Client) HostMetrics ¶
func (c *Client) HostMetrics() (resp explorer.HostMetrics, err error)
HostMetrics returns various metrics about currently available hosts.
func (*Client) OutputSiacoin ¶
func (c *Client) OutputSiacoin(id types.SiacoinOutputID) (resp explorer.SiacoinOutput, err error)
OutputSiacoin returns the specified siacoin output.
func (*Client) OutputSiafund ¶
func (c *Client) OutputSiafund(id types.SiafundOutputID) (resp explorer.SiafundOutput, err error)
OutputSiafund returns the specified siafund output.
func (*Client) State ¶
func (c *Client) State() (resp StateResponse, err error)
State returns information about the current state of the explored daemon.
func (*Client) SyncerBroadcastBlock ¶
SyncerBroadcastBlock broadcasts a block to all peers.
func (*Client) SyncerConnect ¶
SyncerConnect adds the address as a peer of the syncer.
func (*Client) SyncerPeers ¶
SyncerPeers returns the peers of the syncer.
func (*Client) Tip ¶
func (c *Client) Tip() (resp types.ChainIndex, err error)
Tip returns the current tip of the explorer.
func (*Client) Transaction ¶
func (c *Client) Transaction(id types.TransactionID) (resp explorer.Transaction, err error)
Transaction returns the transaction with the specified ID.
func (*Client) TransactionChainIndices ¶
func (c *Client) TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error)
TransactionChainIndices returns chain indices a transaction was included in.
func (*Client) Transactions ¶
func (c *Client) Transactions(ids []types.TransactionID) (resp []explorer.Transaction, err error)
Transactions returns the transactions with the specified IDs.
func (*Client) TxpoolBroadcast ¶
func (c *Client) TxpoolBroadcast(txns []types.Transaction, v2txns []types.V2Transaction) (err error)
TxpoolBroadcast broadcasts a set of transaction to the network.
func (*Client) TxpoolFee ¶
TxpoolFee returns the recommended fee (per weight unit) to ensure a high probability of inclusion in the next block.
func (*Client) TxpoolTransactions ¶
func (c *Client) TxpoolTransactions() (txns []types.Transaction, v2txns []types.V2Transaction, err error)
TxpoolTransactions returns all transactions in the transaction pool.
func (*Client) V2Contract ¶
func (c *Client) V2Contract(id types.FileContractID) (resp explorer.V2FileContract, err error)
V2Contract returns the v2 file contract with the specified ID.
func (*Client) V2ContractRevisions ¶
func (c *Client) V2ContractRevisions(id types.FileContractID) (resp []explorer.V2FileContract, err error)
V2ContractRevisions returns all the revisions of the contract with the specified ID.
func (*Client) V2Contracts ¶
func (c *Client) V2Contracts(ids []types.FileContractID) (resp []explorer.V2FileContract, err error)
V2Contracts returns the v2 contracts with the specified IDs.
func (*Client) V2ContractsKey ¶
V2ContractsKey returns the v2 contracts for a particular ed25519 key.
func (*Client) V2Transaction ¶
func (c *Client) V2Transaction(id types.TransactionID) (resp explorer.V2Transaction, err error)
V2Transaction returns the v2 transaction with the specified ID.
func (*Client) V2TransactionChainIndices ¶
func (c *Client) V2TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error)
V2TransactionChainIndices returns chain indices a v2 transaction was included in.
func (*Client) V2Transactions ¶
func (c *Client) V2Transactions(ids []types.TransactionID) (resp []explorer.V2Transaction, err error)
V2Transactions returns the v2 transactions with the specified IDs.
type Explorer ¶
type Explorer interface { Tip() (types.ChainIndex, error) Block(id types.BlockID) (explorer.Block, error) BestTip(height uint64) (types.ChainIndex, error) Metrics(id types.BlockID) (explorer.Metrics, error) HostMetrics() (explorer.HostMetrics, error) Transactions(ids []types.TransactionID) ([]explorer.Transaction, error) TransactionChainIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error) V2Transactions(ids []types.TransactionID) ([]explorer.V2Transaction, error) V2TransactionChainIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error) Balance(address types.Address) (sc types.Currency, immatureSC types.Currency, sf uint64, err error) SiacoinElements(ids []types.SiacoinOutputID) (result []explorer.SiacoinOutput, err error) SiafundElements(ids []types.SiafundOutputID) (result []explorer.SiafundOutput, err error) UnspentSiacoinOutputs(address types.Address, offset, limit uint64) ([]explorer.SiacoinOutput, error) UnspentSiafundOutputs(address types.Address, offset, limit uint64) ([]explorer.SiafundOutput, error) AddressEvents(address types.Address, offset, limit uint64) (events []explorer.Event, err error) Contracts(ids []types.FileContractID) (result []explorer.ExtendedFileContract, err error) ContractsKey(key types.PublicKey) (result []explorer.ExtendedFileContract, err error) ContractRevisions(id types.FileContractID) (result []explorer.ExtendedFileContract, err error) V2Contracts(ids []types.FileContractID) (result []explorer.V2FileContract, err error) V2ContractsKey(key types.PublicKey) (result []explorer.V2FileContract, err error) V2ContractRevisions(id types.FileContractID) (result []explorer.V2FileContract, err error) Search(id types.Hash256) (explorer.SearchType, error) Hosts(pks []types.PublicKey) ([]explorer.Host, error) }
Explorer implements a Sia explorer.
type GatewayPeer ¶
type GatewayPeer struct { Addr string `json:"addr"` Inbound bool `json:"inbound"` Version string `json:"version"` FirstSeen time.Time `json:"firstSeen"` ConnectedSince time.Time `json:"connectedSince"` SyncedBlocks uint64 `json:"syncedBlocks"` SyncDuration time.Duration `json:"syncDuration"` }
A GatewayPeer is a currently-connected peer.
type StateResponse ¶
type StateResponse struct { Version string `json:"version"` Commit string `json:"commit"` OS string `json:"os"` BuildTime time.Time `json:"buildTime"` StartTime time.Time `json:"startTime"` }
A StateResponse returns information about the current state of the explored daemon.
type Syncer ¶
type Syncer interface { Addr() string Peers() []*syncer.Peer Connect(ctx context.Context, addr string) (*syncer.Peer, error) BroadcastHeader(bh types.BlockHeader) BroadcastTransactionSet(txns []types.Transaction) BroadcastV2TransactionSet(index types.ChainIndex, txns []types.V2Transaction) BroadcastV2BlockOutline(bo gateway.V2BlockOutline) }
A Syncer can connect to other peers and synchronize the blockchain.
type TxpoolBroadcastRequest ¶
type TxpoolBroadcastRequest struct { Transactions []types.Transaction `json:"transactions"` V2Transactions []types.V2Transaction `json:"v2transactions"` }
TxpoolBroadcastRequest is the request type for /txpool/broadcast.
type TxpoolTransactionsResponse ¶
type TxpoolTransactionsResponse struct { Transactions []types.Transaction `json:"transactions"` V2Transactions []types.V2Transaction `json:"v2transactions"` }
TxpoolTransactionsResponse is the response type for /txpool/transactions.