chainread

package
v0.4.1 Latest Latest
Warning

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

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

func ReadRecord added in v0.3.0

func ReadRecord(o lookup.Output, zone [32]byte, now int64) (*zonerec.Kept, error)

ReadRecord reads one output of a records answer (spec section 13) and holds it to its writer: the carrier's output is the canonical PushDrop of the record under derive(writer, "attach") for an attached record or derive(host, "host") for a host record, and the field signature verifies over the record. An attached record must be of the chain asked about, and a record must be live at now (Unix seconds). The carrier's funding is the host's to check (spec section 12.7): a record's signature binds only its signer, so nothing else of it is needed to believe what it says.

func Records added in v0.3.0

func Records(ctx context.Context, host, kind string, zone [32]byte, now int64) (kept []*zonerec.Kept, bad int, err error)

Records asks host for every live record of one records kind (members, hosts, findings, challenges) on chain zone, page by page, and reads each with ReadRecord. A record that does not read is left out and counted in bad: one writer's bad record does not hide the others'.

Types

type CheckError added in v0.1.1

type CheckError struct {
	Seq uint64
	// Number is the check, "C2" to "C7"; 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 C7: 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 GuardError added in v0.3.0

type GuardError struct {
	Seq uint64
	// contains filtered or unexported fields
}

GuardError is a state the guard check marks (spec section 5.1): a protected name changed without the guard's signature, or a guard signature that does not verify. The chain goes on through it, and it is not rendered.

func (*GuardError) Error added in v0.3.0

func (e *GuardError) Error() string

func (*GuardError) Unwrap added in v0.3.0

func (e *GuardError) Unwrap() error

type NoLookupError added in v0.4.0

type NoLookupError struct {
	Host   string
	Status int
}

NoLookupError is a host that does not answer the lookup service: it answers /lookup with 404 or 405, as an overlay-bridge facade does (it takes submissions and answers no lookup).

func (*NoLookupError) Error added in v0.4.0

func (e *NoLookupError) Error() string

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) Guard added in v0.3.0

func (r *Reader) Guard(ctx context.Context, i int) error

Guard runs the guard check over the chain up to and including the state at index i, and returns a *GuardError when that state is marked. Each state is judged against the guarded state before it: the latest earlier state that neither this check nor checks C2 to C7 marked. So every reader decides alike, whatever it rendered. Verdicts are kept by token, and a chain where no state up to i names a guard or carries a guard signature is passed without reading a leaf: the check then passes every state.

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 C7. A state that fails one of C2 to C7 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 C7, 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