Documentation
¶
Overview ¶
Package chainread reads a bdns chain from an overlay host and believes nothing the host says: every token is decoded and held to the chain's rules from seq 0, and every leaves object to the state that commits to it. The command's reads and the renderer both use it.
Index ¶
- func Ask(ctx context.Context, host string, q module.Query) (typ string, body []byte, err error)
- func CheckNumber(label string) string
- func Freeform(ctx context.Context, host string, q module.Query, v any) (bool, error)
- func Outputs(ctx context.Context, host string, q module.Query) ([]lookup.Output, error)
- type CheckError
- type Reader
- type Seen
- type VerifyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNumber ¶
CheckNumber is the check of spec section 8 a label is refused by.
Types ¶
type CheckError ¶ added in v0.1.1
type CheckError struct {
Seq uint64
// Number is the check, "C2" to "C6"; Label its label.
Number, Label string
// contains filtered or unexported fields
}
CheckError is a state whose leaves object is its own (check C1 holds) and fails one of checks C2 to C6: the chain goes on through it, and it is not rendered (spec section 12.2).
func (*CheckError) Error ¶ added in v0.1.1
func (e *CheckError) Error() string
func (*CheckError) Unwrap ¶ added in v0.1.1
func (e *CheckError) Unwrap() error
type Reader ¶
type Reader struct {
Host string
Zone [32]byte
Headers chaintracker.ChainTracker
// Proof, when set, asks the reader's own chain view whether a token
// mined: a host may hold a mined token in the form it first took.
Proof func(ctx context.Context, txid string) (*transaction.MerklePath, uint32, error)
// TxRaw, when set, reads a transaction from the reader's own chain
// view: the anchor's, when the host's BEEF of the first token leaves
// it out.
TxRaw func(ctx context.Context, txid string) ([]byte, error)
// Chain is the states read and verified, from seq 0.
Chain []*Seen
// contains filtered or unexported fields
}
Reader reads one chain from one host.
func (*Reader) Extend ¶
Extend reads the states from seq on and verifies each after the one before it. A state is mined when its own BEEF proves it, when the state after it carries its proof, or when the reader's chain view has one. It returns the first seq that is new, replaced or newly known mined: the chain's length when nothing changed.
func (*Reader) Forget ¶
Forget drops the leaves read for every object but those named: a reader that runs for long keeps only what it still answers from.
func (*Reader) Leaves ¶
Leaves reads a state's leaves object and holds it to the state: its pieces in order, each of this object, then checks C1 to C6. A state that fails one of C2 to C6 is a *CheckError; one that fails C1 a VerifyError.
type Seen ¶
type Seen struct {
St *zonerec.State
Tx *transaction.Transaction
Vout uint32
Beef []byte
Mined bool
Height uint32
}
Seen is one state as a host answered it: its token, and whether the token's BEEF proves it.
func ReadLog ¶
func ReadLog(ctx context.Context, host string, zone [32]byte, from uint64, limit int) ([]*Seen, error)
ReadLog asks for the states from seq, at most limit, and decodes each token. It verifies nothing.
func (*Seen) Outpoint ¶
func (s *Seen) Outpoint() transaction.Outpoint
Outpoint is the token's outpoint.
type VerifyError ¶
type VerifyError struct {
// contains filtered or unexported fields
}
VerifyError is what a host answered that does not verify.
func (*VerifyError) Error ¶
func (e *VerifyError) Error() string
func (*VerifyError) Unwrap ¶
func (e *VerifyError) Unwrap() error