Documentation
¶
Index ¶
- func AuthMiddleware(handler http.Handler, requiredPass string) http.Handler
- func NewServer(cm ChainManager, s Syncer, tp TransactionPool, e Explorer) http.Handler
- type ChainManager
- type Client
- func (c *Client) AddressBalance(address types.Address) (resp ExplorerWalletBalanceResponse, err error)
- func (c *Client) BatchBalance(addresses []types.Address) (resp []ExplorerWalletBalanceResponse, err error)
- func (c *Client) BatchSiacoins(addresses []types.Address) (resp [][]types.SiacoinElement, err error)
- func (c *Client) BatchSiafunds(addresses []types.Address) (resp [][]types.SiafundElement, err error)
- func (c *Client) BatchTransactions(addresses []ExplorerTransactionsRequest) (resp [][]types.Transaction, err error)
- func (c *Client) ChainState(index types.ChainIndex) (resp consensus.State, err error)
- func (c *Client) ChainStats(index types.ChainIndex) (resp explorer.ChainStats, err error)
- func (c *Client) ElementSearch(id types.ElementID) (resp ExplorerSearchResponse, err error)
- func (c *Client) FileContractElement(id types.ElementID) (resp types.FileContractElement, err error)
- func (c *Client) SiacoinElement(id types.ElementID) (resp types.SiacoinElement, err error)
- func (c *Client) SiacoinOutputs(address types.Address) (resp []types.ElementID, err error)
- func (c *Client) SiafundElement(id types.ElementID) (resp types.SiafundElement, err error)
- func (c *Client) SiafundOutputs(address types.Address) (resp []types.ElementID, err error)
- func (c *Client) SyncerConnect(addr string) (err error)
- func (c *Client) SyncerPeers() (resp []SyncerPeerResponse, err error)
- func (c *Client) Transaction(id types.TransactionID) (resp types.Transaction, err error)
- func (c *Client) Transactions(address types.Address, amount, offset int) (resp []types.TransactionID, err error)
- func (c *Client) TxpoolBroadcast(txn types.Transaction, dependsOn []types.Transaction) (err error)
- func (c *Client) TxpoolTransactions() (resp []types.Transaction, err error)
- type Explorer
- type ExplorerSearchResponse
- type ExplorerTransactionsRequest
- type ExplorerWalletBalanceResponse
- type Syncer
- type SyncerPeerResponse
- type TransactionPool
- type TxpoolBroadcastRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
AuthMiddleware enforces HTTP Basic Authentication on the provided handler.
func NewServer ¶
func NewServer(cm ChainManager, s Syncer, tp TransactionPool, e Explorer) http.Handler
NewServer returns an HTTP handler that serves the explorerd API.
Types ¶
type ChainManager ¶
A ChainManager manages blockchain state.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client provides methods for interacting with a explorer API server.
func NewClient ¶
NewClient returns a client that communicates with a explorer server listening on the specified address.
func (*Client) AddressBalance ¶
func (c *Client) AddressBalance(address types.Address) (resp ExplorerWalletBalanceResponse, err error)
AddressBalance returns the siacoin and siafund balance of an address.
func (*Client) BatchBalance ¶
func (c *Client) BatchBalance(addresses []types.Address) (resp []ExplorerWalletBalanceResponse, err error)
BatchBalance returns the siacoin and siafund balance of a list of addresses.
func (*Client) BatchSiacoins ¶
func (c *Client) BatchSiacoins(addresses []types.Address) (resp [][]types.SiacoinElement, err error)
BatchSiacoins returns the unspent siacoin elements of the addresses.
func (*Client) BatchSiafunds ¶
func (c *Client) BatchSiafunds(addresses []types.Address) (resp [][]types.SiafundElement, err error)
BatchSiafunds returns the unspent siafund elements of the addresses.
func (*Client) BatchTransactions ¶
func (c *Client) BatchTransactions(addresses []ExplorerTransactionsRequest) (resp [][]types.Transaction, err error)
BatchTransactions returns the last n transactions of the addresses.
func (*Client) ChainState ¶
ChainState returns the validation context at a given chain index.
func (*Client) ChainStats ¶
func (c *Client) ChainStats(index types.ChainIndex) (resp explorer.ChainStats, err error)
ChainStats returns stats about the chain at the given index.
func (*Client) ElementSearch ¶
func (c *Client) ElementSearch(id types.ElementID) (resp ExplorerSearchResponse, err error)
ElementSearch returns information about a given element.
func (*Client) FileContractElement ¶
func (c *Client) FileContractElement(id types.ElementID) (resp types.FileContractElement, err error)
FileContractElement returns the file contract element with the given ID.
func (*Client) SiacoinElement ¶
SiacoinElement returns the Siacoin element with the given ID.
func (*Client) SiacoinOutputs ¶
SiacoinOutputs returns the unspent siacoin elements of an address.
func (*Client) SiafundElement ¶
SiafundElement returns the Siafund element with the given ID.
func (*Client) SiafundOutputs ¶
SiafundOutputs returns the unspent siafunds elements of an address.
func (*Client) SyncerConnect ¶
SyncerConnect adds the address as a peer of the syncer.
func (*Client) SyncerPeers ¶
func (c *Client) SyncerPeers() (resp []SyncerPeerResponse, err error)
SyncerPeers returns the current peers of the syncer.
func (*Client) Transaction ¶
func (c *Client) Transaction(id types.TransactionID) (resp types.Transaction, err error)
Transaction returns a transaction with the given ID.
func (*Client) Transactions ¶
func (c *Client) Transactions(address types.Address, amount, offset int) (resp []types.TransactionID, err error)
Transactions returns the latest transaction IDs the address was involved in.
func (*Client) TxpoolBroadcast ¶
func (c *Client) TxpoolBroadcast(txn types.Transaction, dependsOn []types.Transaction) (err error)
TxpoolBroadcast broadcasts a transaction to the network.
func (*Client) TxpoolTransactions ¶
func (c *Client) TxpoolTransactions() (resp []types.Transaction, err error)
TxpoolTransactions returns all transactions in the transaction pool.
type Explorer ¶
type Explorer interface { SiacoinElement(id types.ElementID) (types.SiacoinElement, error) SiafundElement(id types.ElementID) (types.SiafundElement, error) FileContractElement(id types.ElementID) (types.FileContractElement, error) ChainStats(index types.ChainIndex) (explorer.ChainStats, error) ChainStatsLatest() (explorer.ChainStats, error) SiacoinBalance(address types.Address) (types.Currency, error) SiafundBalance(address types.Address) (uint64, error) Transaction(id types.TransactionID) (types.Transaction, error) UnspentSiacoinElements(address types.Address) ([]types.ElementID, error) UnspentSiafundElements(address types.Address) ([]types.ElementID, error) Transactions(address types.Address, amount, offset int) ([]types.TransactionID, error) State(index types.ChainIndex) (context consensus.State, err error) }
An Explorer contains a database storing information about blocks, outputs, contracts.
type ExplorerSearchResponse ¶
type ExplorerSearchResponse struct { Type string `json:"type"` SiacoinElement types.SiacoinElement `json:"siacoinElement"` SiafundElement types.SiafundElement `json:"siafundElement"` FileContractElement types.FileContractElement `json:"fileContractElement"` }
A ExplorerSearchResponse contains information about an element.
type ExplorerTransactionsRequest ¶
type ExplorerTransactionsRequest struct { Address types.Address `json:"address"` Amount int `json:"amount"` Offset int `json:"offset"` }
A ExplorerTransactionsRequest contains an address and the amount of transactions involving the address to request.
type ExplorerWalletBalanceResponse ¶
type ExplorerWalletBalanceResponse struct { Siacoins types.Currency `json:"siacoins"` Siafunds uint64 `json:"siafunds"` }
A ExplorerWalletBalanceResponse contains the confirmed Siacoin and Siafund balance of the wallet.
type Syncer ¶
type Syncer interface { Addr() string Peers() []string Connect(addr string) error BroadcastTransaction(txn types.Transaction, dependsOn []types.Transaction) }
A Syncer can connect to other peers and synchronize the blockchain.
type SyncerPeerResponse ¶
type SyncerPeerResponse struct {
NetAddress string `json:"netAddress"`
}
A SyncerPeerResponse is a unique peer that is being used by the syncer.
type TransactionPool ¶
type TransactionPool interface { Transactions() []types.Transaction AddTransaction(txn types.Transaction) error }
A TransactionPool can validate and relay unconfirmed transactions.
type TxpoolBroadcastRequest ¶
type TxpoolBroadcastRequest struct { DependsOn []types.Transaction `json:"dependsOn"` Transaction types.Transaction `json:"transaction"` }
TxpoolBroadcastRequest is the request for the /txpool/broadcast endpoint. It contains the transaction to broadcast and the transactions that it depends on.