testhost

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 31 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 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

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

func NewBorg(dir, chainURL string, hosts ...*Host) (*Borg, error)

NewBorg makes an organisation whose home is dir, funded from the chain served at chainURL, in a new hall the hosts carry.

func (*Borg) Add

func (b *Borg) Add(group string, member []byte) error

Add adds one member under the current epoch.

func (*Borg) Change

func (b *Borg) Change(group string, add, remove [][]byte, rotate bool) error

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

func (b *Borg) CreateGroup(name string, members ...[]byte) (string, error)

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) Epoch

func (b *Borg) Epoch(group string) uint64

Epoch is a group's current epoch.

func (*Borg) Identity

func (b *Borg) Identity() string

Identity is the organisation's identity key, hex.

func (*Borg) Key

func (b *Borg) Key() []byte

Key is the organisation's identity key, compressed.

func (*Borg) LatestToken

func (b *Borg) LatestToken(group string) string

LatestToken is the txid of a group's latest token.

func (*Borg) Remove

func (b *Borg) Remove(group string, member []byte) error

Remove removes one member: a new epoch.

func (*Borg) Rotate

func (b *Borg) Rotate(group string) error

Rotate begins a new epoch with the same members.

func (*Borg) Signer

func (b *Borg) Signer() []byte

Signer is the organisation's signer key, compressed.

func (*Borg) Wrap

func (b *Borg) Wrap(group string) error

Wrap publishes the wraps a group's current epoch owes its members.

type Chain

type Chain = bc.Chain

Chain is the shared local chain.

func NewChain

func NewChain(start uint32) *Chain

NewChain is a chain whose tip is at height start.

type Host

type Host struct {

	// Down answers every request with 503.
	Down bool
	// Priced refuses the priceable classes on /lookup.
	Priced 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 NewHost

func NewHost(chain *Chain) *Host

NewHost is a host whose engine checks proofs against chain.

func (*Host) Answer

func (h *Host) Answer(q *secrec.Question) ([]Output, error)

Answer answers a validated ls_bsecret question.

func (*Host) Carry

func (h *Host) Carry(crypt string)

Carry adds a crypt.

func (*Host) CarryHall

func (h *Host) CarryHall(hall string)

CarryHall adds a borg hall.

func (*Host) Forget

func (h *Host) Forget(txid string)

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

func (h *Host) ForgetHall(txid string)

ForgetHall drops a borg object, as a hall's host that lost it, or withholds it, would.

func (*Host) Holds

func (h *Host) Holds(txid string) bool

Holds reports whether the host holds a bsecret object with txid.

func (*Host) Questions

func (h *Host) Questions(class string) int

Questions is how many ls_bsecret questions of a class the host answered.

func (*Host) ServeHTTP

func (h *Host) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Host) SetDown

func (h *Host) SetDown(down bool)

SetDown takes the host down or brings it back.

func (*Host) Status

func (h *Host) Status(txid string) string

Status is the status of a carrier the host holds, or "".

func (*Host) Take

func (h *Host) Take(topic string, beef []byte) (bool, error)

Take offers a BEEF to the host under a topic, as a submission does, and reports whether it admitted anything.

func (*Host) Txids

func (h *Host) Txids(kind string) []string

Txids are the txids of the bsecret objects the host holds of a kind: "secret", "token" or "sweep", sorted.

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 = paidhost.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.

func NewPaid

func NewPaid(host *Host, payee *ec.PrivateKey, prices map[string]uint64) *Paid

NewPaid is a terms route for host, paid to payee: ls_bsecret's classes, its questions parsed by secrec and answered by the host.

type Payment

type Payment = paidhost.Payment

Payment is one accepted payment, in the host ledger's shape.

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.

func (*Plane) ServeHTTP

func (p *Plane) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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