Documentation
¶
Overview ¶
Package testchain is the local stand-ins this module's tests run against: the shared chain, and this application's host.
Index ¶
- Constants
- type Chain
- type Host
- func (h *Host) Answer(q *borgrec.Question) ([]Output, error)
- func (h *Host) Carry(hall string)
- func (h *Host) Forget(txid string)
- func (h *Host) Holds(txid string) bool
- 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) Txids(kind string) []string
- type Output
- type Paid
- type Payment
- type Plane
Constants ¶
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 Host ¶
type Host struct {
// 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
// Rewrite, when set, rewrites the answer to an ls_borg question on
// /lookup: a host that withholds, adds or repeats outputs.
Rewrite 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 reorganization left behind.
Stale bool
// HistoryPage, when set, is the most tokens 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 borg halls: /submit runs the engine's SPV and the borg topic manager (borgrec.Admit) over the topic's previous coins, and /lookup answers the ls_borg classes from an index that folds each chain from seq 0 and keeps one outpoint row per funding outpoint (spec sections 10.2, 11.1 and 11.2). 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 caps 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.
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 (spec 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.