Documentation
¶
Overview ¶
Package config resolves the blogs command's settings: flags, then BLOGS_* in the environment, then the config file, then the built-in default.
The overlay hosts and the facade have no default: a default there would quietly send a producer's objects or a reader's questions to somebody else's server, so a command that needs one and finds none is a usage error. The chain services do, on mainnet and testnet, so that a producer needs no infrastructure of its own (WithDefaults): WhatsOnChain for headers and the chain view, GorillaPool's public arcade to broadcast. Every one of them is a setting, and a node of one's own is the better choice where there is one. A regtest chain has no public services and so no defaults.
Index ¶
Constants ¶
const ( ModePlane = "plane" ModeUnicast = "unicast" QuorumAll = "all" QuorumMajority = "majority" QuorumOne = "one" )
The modes and the named quorums.
const DefaultObjectBound = 1 << 20
DefaultObjectBound is the object bound assumed when none is configured.
Variables ¶
var ErrUnknownKey = errors.New("config: unknown key")
ErrUnknownKey reports a key the grammar does not define.
var Keys = []string{"arcade_key", "asset", "chain", "facade", "fee_dust", "fee_floor", "fee_max_rate", "fee_max_tx",
"fee_min_rate", "fee_policy_urls", "fee_rate", "fee_source", "fund_mined_only", "header_url", "home", "hosts", "mode",
"network", "object_bound", "originator", "quorum", "rpc", "rpc_pass", "rpc_user", "settle", "timeout", "tx_source", "woc_key", "woc_rate"}
Keys is the file grammar's key list, in lexicographic order. A key not in it is an error: a misspelt key that was silently ignored would leave a setting at its default with no sign that the file was ever read.
Functions ¶
func DefaultHome ¶
func DefaultHome() string
DefaultHome is ~/.blogs, or .blogs when there is no home directory.
func Need ¶
Need is how many of n hosts the quorum q requires. q is one Apply accepted; a number above n is an error, because a quorum no host set can meet would refuse every publish.
Types ¶
type Config ¶
type Config struct {
// ArcadeKey is the bearer token for the arcade or ARC installation in
// Settle.
ArcadeKey string
// Asset is a node's asset API base URL. It is the chain view when Chain
// is not set (asset:<Asset>), and the node coinbase is read from on a
// regtest chain.
Asset string
// Chain is the chain view (nodeapi.ParseChain): where transactions,
// proofs and spends are read. woc:main or woc:test (WhatsOnChain, no
// node), asset:URL (a node), or a comma-separated combination.
Chain string
// Facade is the overlay host a producer publishes to.
Facade string
// The fee settings (feepolicy.Config), as written: fee_rate,
// fee_min_rate and fee_max_rate are sats/bytes, the others whole
// numbers, a source name or a URL list. Empty is the default.
FeeDust, FeeFloor, FeeMaxRate, FeeMaxTx, FeeMinRate, FeePolicyURLs, FeeRate, FeeSource string
// FundMinedOnly refuses a funding payment (fund -beef) that has not
// mined yet.
FundMinedOnly bool
// HeaderURL is the header source every proof is checked against:
// woc:main, woc:test, bhs:URL, arcade:URL, chaintracks:URL or a
// bridge's /v1 base URL.
HeaderURL string
// Home is the producer's directory: identity, coin pool and streams.
Home string
// Hosts are the overlay hosts a reader asks, in order. In unicast mode
// they are also every host a producer submits to.
Hosts []string
// Mode is how a producer's objects reach the hosts: "plane" (one
// submit to Facade, which the multicast plane delivers to every
// subscribed host) or "unicast" (one submit to each of Hosts).
Mode string
// Network is "main", "test" or "regtest". It picks the fund address's
// prefix and the proof-of-work floor a header source is held to.
Network string
// ObjectBound is the largest object the plane takes, in bytes: a
// carrier's BEEF over it is not published.
ObjectBound int
// Originator is the BRC-100 originator presented to the wallet.
Originator string
// Quorum is, in unicast mode, how many of Hosts must take an object
// for it to count as published: "all", "majority", "one", or a number.
Quorum string
// RPC is the node's JSON-RPC URL; RPCUser and RPCPass its basic auth.
RPC string
RPCPass string
RPCUser string
// Settle is the settlement leg (publish.ParseSettler): arcade:main,
// arcade:test, arcade:<url>, arc:<url>, rpc:<url> or tcp:<host:port>.
Settle string
// Timeout bounds each request to a host, node or header source.
Timeout time.Duration
// TxSource is the older name of a WhatsOnChain chain view, woc:main or
// woc:test: the chain view when neither Chain nor Asset is set.
TxSource string
// WoCKey is a WhatsOnChain API key, and WoCRate the requests a second
// its plan allows; zero is the free tier's 3.
WoCKey string
WoCRate float64
}
Config is the resolved settings.
func Load ¶
Load resolves the file (a missing one is fine) and the environment over the defaults. Flags are applied by the caller afterwards with Apply, because only the caller knows which flags were set.
func (Config) Apply ¶
Apply sets the given keys the same way for a file, the environment or flags, so all three parse alike.
func (Config) FeeConfig ¶ added in v0.2.0
FeeConfig is the fee settings as a feepolicy.Config; Apply has checked each of them.
func (Config) WithDefaults ¶ added in v0.2.0
WithDefaults fills in the chain services a network has defaults for: the chain view (asset:<Asset> when a node is configured, else tx_source, else woc:<network>), the header source (woc:<network>) and the settlement leg (publish.DefaultSettle: GorillaPool's public arcade). A regtest chain gets only the node as its chain view.