Documentation
¶
Overview ¶
Package testhost is the local stand-ins this module's tests run against: an overlay host that carries bsecret crypts and borg halls, a plane, a terms route, and an organisation's borg tooling reduced to what a vault needs of it. Nothing here is for real use.
Index ¶
- type Borg
- func (b *Borg) Add(group string, member []byte) error
- func (b *Borg) Change(group string, add, remove [][]byte, rotate bool) error
- func (b *Borg) CreateGroup(name string, members ...[]byte) (string, error)
- func (b *Borg) Epoch(group string) uint64
- func (b *Borg) Identity() string
- func (b *Borg) Key() []byte
- func (b *Borg) LatestToken(group string) string
- func (b *Borg) Remove(group string, member []byte) error
- func (b *Borg) Rotate(group string) error
- func (b *Borg) Signer() []byte
- func (b *Borg) Wrap(group string) error
- type Chain
- type Host
- func (h *Host) Answer(q *secrec.Question) ([]Output, error)
- func (h *Host) Carry(crypt string)
- func (h *Host) CarryHall(hall string)
- func (h *Host) Forget(txid string)
- func (h *Host) ForgetHall(txid string)
- func (h *Host) Holds(txid string) bool
- func (h *Host) Questions(class string) int
- func (h *Host) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Host) SetDown(down bool)
- func (h *Host) Status(txid string) string
- func (h *Host) Take(topic string, beef []byte) (bool, error)
- func (h *Host) Txids(kind string) []string
- type Output
- type Paid
- type Payment
- type Plane
- type Private
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Borg ¶
type Borg struct {
Home string
Hall string
// NoWraps holds back the wraps of every epoch begun while it is set,
// until Wrap is called: a new epoch whose key is not yet released.
NoWraps bool
// NoSigner leaves the organisation's signer key out of new groups.
NoSigner bool
// contains filtered or unexported fields
}
Borg is an organisation's borg tooling reduced to what a vault needs of it: a hall, groups whose tokens are real mined transactions under borg's own derivations and records (borgrec), epoch keys sampled at random and wrapped to each member and to the organisation's signer key, and removals that begin a new epoch. Its home holds an identity.json as a borg home does, which is what a bsecret home is made around. It issues no grant and keeps no organisation chain: neither a host's admission of a group token nor a vault's reader looks at one.
func NewBorg ¶
NewBorg makes an organisation whose home is dir, funded from the chain served at chainURL, in a new hall the hosts carry.
func (*Borg) Change ¶
Change mints the group's next token: add and remove members; a removal, or rotate, begins a new epoch with a fresh key, wrapped to the members who remain.
func (*Borg) CreateGroup ¶
CreateGroup creates a group of members (identity keys, compressed), with the organisation's signer key among them, and wraps epoch 0's key to each. It returns the group's identifier, hex.
func (*Borg) LatestToken ¶
LatestToken is the txid of a group's latest token.
type Host ¶
type Host struct {
// Down answers every request with 503.
Down bool
// Priced refuses the priceable classes on /lookup.
Priced bool
// Private are the crypts whose questions /lookup refuses: they are
// asked over BRC-104 at a route (NewPrivate).
Private map[string]bool
// Drop, when set, is asked about each submission; true discards it
// unseen, as a plane that lost the object would.
Drop func(tx *transaction.Transaction) bool
// Substitute, when set, rewrites a carrier's answered BEEF: a host
// that serves other bytes.
Substitute func(beef []byte) []byte
// Rewrite, when set, rewrites the answer to an ls_bsecret question: a
// host that withholds, adds or repeats outputs.
Rewrite func(q *secrec.Question, outs []Output) []Output
// RewriteBorg, when set, rewrites the answer to an ls_borg question: a
// hall's host that withholds a wrap, or serves other bytes for one.
RewriteBorg func(q *borgrec.Question, outs []Output) []Output
// Stale answers every token, carrier and sweep under a proof that names
// another block than the one the chain mined it in: a host whose stored
// proofs a reorganisation left behind.
Stale bool
// Submits counts submissions; Refused counts refusals by reason; Asked
// counts the ls_bsecret questions answered, by class.
Submits int
Refused map[string]int
Asked map[string]int
// contains filtered or unexported fields
}
Host is a stand-in overlay host carrying bsecret crypts and borg halls. For a crypt, /submit runs the engine's SPV and the bsecret topic manager (secrec.Admit) over the topic's previous coins, and /lookup answers the ls_bsecret classes from an index that keeps only rooted tokens as a vault's chain, folds it, and keeps one outpoint row per funding outpoint (docs/spec.md sections 10.2, 11.1 and 11.2). For a hall it admits by borg's own rules (borgrec.Admit) and answers the ls_borg classes a vault's reader asks. A refusal is recorded nowhere, so the same transaction offered again is decided afresh. The priced classes are refused on /lookup when Priced is set, as a host that sells them refuses them there. Retention, restore and the bounded tables are the real module's and are not modelled.
func (*Host) Forget ¶
Forget drops an object, as a host that lost it would: an honest host does not, but a test makes one that did.
func (*Host) ForgetHall ¶
ForgetHall drops a borg object, as a hall's host that lost it, or withholds it, would.
type Output ¶
type Output struct {
Beef []byte `json:"beef"`
OutputIndex int `json:"outputIndex"`
Context []byte `json:"context,omitempty"`
}
Output is one answered output.
type Paid ¶
Paid is a stand-in for a host's terms route (docs/spec.md section 10.3): devkit's paidhost answering from a Host.
type Plane ¶
type Plane struct {
Hosts []http.Handler
// Lost, when set, is asked per host and submission; true loses the
// object on the way to that host.
Lost func(host int, tx []byte) bool
}
Plane stands in for the multicast plane: a facade that delivers each submission to every host subscribed to the topic, answering with the first host's answer. Lookups go to the first host, the facade's own.
type Private ¶ added in v0.6.0
type Private struct {
// Allowed says whether a private crypt is served to an identity key.
Allowed func(crypt, identity string) bool
// contains filtered or unexported fields
}
Private is a stand-in for a host whose crypts are private (docs/spec.md section 10.4): its /lookup and /.well-known/auth are a terms route that answers ls_bsecret over BRC-104, about a private crypt only to the askers Allowed names, and every other path is the host's own, whose /lookup refuses every question about a private crypt.
func NewPrivate ¶ added in v0.6.0
func NewPrivate(host *Host, key *ec.PrivateKey, crypt string, allowed func(crypt, identity string) bool) *Private
NewPrivate makes crypt private on host, behind a route whose BRC-104 identity is key.