chainread

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 15 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 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ask

func Ask(ctx context.Context, host string, q module.Query) (typ string, body []byte, err error)

Ask puts a question to ls_bdns on one host and returns the raw answer.

func CheckNumber

func CheckNumber(label string) string

CheckNumber is the check of spec section 8 a label is refused by.

func Freeform

func Freeform(ctx context.Context, host string, q module.Query, v any) (bool, error)

Freeform is a freeform answer's result, read into v; false for null.

func Outputs

func Outputs(ctx context.Context, host string, q module.Query) ([]lookup.Output, error)

Outputs is an output-list answer.

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

func (r *Reader) Extend(ctx context.Context, from uint64) (int, error)

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

func (r *Reader) Forget(keep ...[32]byte)

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

func (r *Reader) Leaves(ctx context.Context, s *Seen) ([]*zonerec.Leaf, error)

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.

func (*Reader) Opened added in v0.1.1

func (r *Reader) Opened(ctx context.Context, s *Seen) ([]*zonerec.Leaf, *CheckError, error)

Opened is Leaves that also gives the leaves of a state that fails one of checks C2 to C6, with the *CheckError: what the chain holds at that state, which is not rendered. A state's object that is not its own (C1) is an error.

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

Jump to

Keyboard shortcuts

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