api

package
v0.0.0-...-9bc7f68 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(handler http.Handler, requiredPass string) http.Handler

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

type ChainManager interface {
	TipState() consensus.State
}

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

func NewClient(addr, password string) *Client

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

func (c *Client) ChainState(index types.ChainIndex) (resp consensus.State, err error)

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

func (c *Client) SiacoinElement(id types.ElementID) (resp types.SiacoinElement, err error)

SiacoinElement returns the Siacoin element with the given ID.

func (*Client) SiacoinOutputs

func (c *Client) SiacoinOutputs(address types.Address) (resp []types.ElementID, err error)

SiacoinOutputs returns the unspent siacoin elements of an address.

func (*Client) SiafundElement

func (c *Client) SiafundElement(id types.ElementID) (resp types.SiafundElement, err error)

SiafundElement returns the Siafund element with the given ID.

func (*Client) SiafundOutputs

func (c *Client) SiafundOutputs(address types.Address) (resp []types.ElementID, err error)

SiafundOutputs returns the unspent siafunds elements of an address.

func (*Client) SyncerConnect

func (c *Client) SyncerConnect(addr string) (err error)

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.

Jump to

Keyboard shortcuts

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