testchain

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 18 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 testchain is the local stand-ins this module's tests run against: the shared chain, and this application's host. Coinbase: only on a regtest chain you run (development and tests).

Index

Constants

View Source
const (
	CoinbaseValue = bc.CoinbaseValue
	Maturity      = bc.Maturity
)

CoinbaseValue and Maturity are the chain's.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain = bc.Chain

Chain is the shared local chain.

func New

func New(start uint32) *Chain

New is a chain whose tip is at height start.

type Host

type Host struct {

	// Now is the host's clock.
	Now func() time.Time
	// Down answers every request with 503.
	Down bool
	// Priced refuses the history 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
	// Tamper, when set, rewrites every answered BEEF, as a host that edits
	// what it serves would.
	Tamper func(beef []byte) []byte
	// Stale answers every carrier under a proof of its funding tree that
	// names another block than the one the chain mined it in: a host whose
	// stored proofs a reorganization left behind.
	Stale bool
	// HistoryPage, when set, is the most envelopes a history page holds
	// here, in place of the class's 64.
	HistoryPage int
	// Submits counts submissions; Refused counts refusals by reason.
	Submits int
	Refused map[string]int
	// contains filtered or unexported fields
}

Host is a stand-in overlay host carrying bbox offices: /submit runs the engine's SPV and the bbox topic manager (boxrec.Admit) over the topic's previous coins, and /lookup answers the ls_bbox classes by the statuses of spec section 8.2 and the answer window of section 8.3. 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 evidence cap are the real module's and are not modelled.

func NewHost

func NewHost(chain *Chain, offices ...string) *Host

NewHost is a host carrying offices whose engine checks proofs against chain.

func (*Host) Answer

func (h *Host) Answer(q *boxrec.Question) []Output

Answer answers a validated question. The caller holds the lock.

func (*Host) Carry

func (h *Host) Carry(office string)

Carry adds an office.

func (*Host) Holds

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

Holds reports whether the host holds a carrier or sweep with txid.

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 a carrier's status (spec section 8.2).

type Output

type Output struct {
	Beef        []byte `json:"beef"`
	OutputIndex int    `json:"outputIndex"`
}

Output is one answered output.

type Paid = paidhost.Paid

Paid is a stand-in for a host's terms route (spec sections 7.3 and 7.4): 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_bbox's classes, its questions parsed by boxrec 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