config

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config resolves the borg command's settings: flags, then BORG_* in the environment, then the config file, then the built-in default.

The deployment addresses have no default: the overlay hosts, the facade, the header source, the settlement leg, the node and the host a priced question goes to. A default there would quietly send an organisation's records, or a member's questions, to somebody else's server, so a command that needs one and finds none is a usage error.

Index

Constants

View Source
const (
	ModePlane      = "plane"
	ModeUnicast    = "unicast"
	QuorumAll      = "all"
	QuorumMajority = "majority"
	QuorumOne      = "one"
)

The modes and the named quorums.

Variables

View Source
var ErrUnknownKey = errors.New("config: unknown key")

ErrUnknownKey reports a key the grammar does not define.

View Source
var Keys = []string{"arcade_key", "asset", "chain_tree_count", "delay", "entries", "facade", "freshness", "hall", "header_url",
	"history_host", "home", "hosts", "mode", "network", "object_bound", "org", "originator", "quorum", "rpc", "rpc_pass",
	"rpc_user", "settle", "signers", "timeout", "tree_count"}

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 ~/.borg, or .borg when there is no home directory.

func IsKeyHex

func IsKeyHex(s string) bool

IsKeyHex reports whether s is an identity key: 66 lowercase hex digits whose bytes meet the key rule.

func Need

func Need(q string, n int) (int, error)

Need is how many of n hosts the quorum q requires. A number above n is an error: a quorum no host set can meet would refuse every publish.

func Parse

func Parse(r io.Reader) (map[string]string, error)

Parse reads the key = value grammar: one setting per line, '#' comments, blank lines ignored, a key at most once.

func Path

func Path(flagPath string, getenv func(string) string) string

Path is the config file location: the -config flag, else $BORG_HOME/config, else $XDG_CONFIG_HOME/borg/config, else ~/.borg/config.

Types

type Config

type Config struct {
	// ArcadeKey is the bearer token for an arcade installation in Settle.
	ArcadeKey string
	// Asset is the node's asset API base URL: proofs, the chain tip, raw
	// transactions and the node's view of which outputs are spent.
	Asset string
	// ChainTreeCount is how many outputs a new chain tree has.
	ChainTreeCount int
	// Delay is the propagation delay: how long after a mined object's
	// block is in the publisher's headers it is published (spec section
	// 7.2).
	Delay time.Duration
	// Entries is the most wrap entries one wrap record carries; zero is the
	// mode's default (8 on the plane, 16 in unicast).
	Entries int
	// Facade is the overlay host a publisher submits to in mode plane.
	Facade string
	// Freshness bounds how old a writer's evidence that a group's token is
	// the latest may be (spec section 6.5).
	Freshness time.Duration
	// Hall is the hall identifier <name>_<suffix> a command uses when it
	// names none.
	Hall string
	// HeaderURL is the header source every proof is checked against: a
	// bridge's /v1 base URL, woc:main, woc:test or chaintracks:URL. No
	// default, ever.
	HeaderURL string
	// HistoryHost is the base URL of ls_borg on the host a priced history
	// question is asked of: the host's terms route (spec section 10.3).
	HistoryHost string
	// Home is the identity's directory: key, coin pool and state.
	Home string
	// Hosts are the overlay hosts a reader asks. In mode unicast they are
	// every host a publisher submits to; in mode plane mined objects also
	// go to each of them directly.
	Hosts []string
	// Mode is how a publisher's objects reach the hosts: "plane" or
	// "unicast".
	Mode string
	// Network is "main", "test" or "regtest".
	Network string
	// ObjectBound is the largest object the plane takes, in bytes.
	ObjectBound int
	// Org is the organisation a member's command reads when it names none:
	// its identity key, 66 lowercase hex digits.
	Org string
	// Originator is the BRC-100 originator presented to the wallet.
	Originator string
	// Quorum is, in mode unicast, how many of Hosts must take a carrier for
	// it to count as published: "all", "majority", "one" or a number.
	// Tokens and sweeps always need every host.
	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 mined transactions go to: tcp:<host:port>,
	// rpc:<url> or arcade:<url>.
	Settle string
	// Signers is how many instances of the organisation's tooling can sign
	// transitions. Above one, wraps wait one further block (spec section
	// 7.2).
	Signers int
	// Timeout bounds each request to a host, node or header source.
	Timeout time.Duration
	// TreeCount is how many outputs a new grant or record funding tree has.
	TreeCount int
}

Config is the resolved settings.

func Defaults

func Defaults() Config

Defaults are the built-in values for the keys that have one.

func Load

func Load(path string, getenv func(string) string) (Config, error)

Load resolves the file (a missing one is fine) and the environment over the defaults. Flags are applied by the caller afterwards with Apply.

func (Config) Apply

func (c Config) Apply(vals map[string]string) (Config, error)

Apply sets the given keys the same way for a file, the environment or flags, so all three parse alike.

func (Config) EntriesFor

func (c Config) EntriesFor() int

EntriesFor is the wrap entries per record the mode takes when Entries is unset.

Jump to

Keyboard shortcuts

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