Documentation
¶
Overview ¶
Package blockchaininfo is the library behind the blockchain-info command line: the HTTP client, request shaping, and the typed data models for blockchain.info.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "blockchain-info-cli/dev (+https://github.com/tamnd/blockchain-info-cli)"
DefaultUserAgent identifies the client to blockchain.info.
const Host = "blockchain.info"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
Hash string `kit:"id" json:"hash"`
Height int `json:"height"`
Time int64 `json:"time"`
TxCount int `json:"tx_count"`
Size int `json:"size"`
Difficulty float64 `json:"difficulty"`
Nonce int64 `json:"nonce"`
Weight int `json:"weight"`
}
Block holds summary data for one block from /block-height/{height}?format=json.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to blockchain.info over HTTP.
type Conversion ¶
type Conversion struct {
Currency string `kit:"id" json:"currency"`
Value float64 `json:"fiat_value"`
BTC float64 `json:"btc"`
}
Conversion holds the result of converting a fiat amount to BTC.
type Domain ¶
type Domain struct{}
Domain is the blockchain-info driver.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). Numeric string → ("height", input); 3-letter uppercase → ("currency", input).
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Stats ¶
type Stats struct {
MarketPriceUSD float64 `kit:"id" json:"market_price_usd"`
HashRate float64 `json:"hash_rate"`
TotalBlocksMined int64 `json:"total_blocks_mined"`
TotalBTCMinted int64 `json:"total_btc_minted_satoshi"`
TotalTransactions int64 `json:"total_transactions"`
Difficulty float64 `json:"difficulty"`
MinutesBetweenBlocks float64 `json:"minutes_between_blocks"`
}
Stats holds network statistics from /stats?format=json.