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)
- func ReadRecord(o lookup.Output, zone [32]byte, now int64) (*zonerec.Kept, error)
- func Records(ctx context.Context, host, kind string, zone [32]byte, now int64) (kept []*zonerec.Kept, bad int, err error)
- type CheckError
- type GuardError
- type NoLookupError
- type Reader
- func (r *Reader) Extend(ctx context.Context, from uint64) (int, error)
- func (r *Reader) Forget(keep ...[32]byte)
- func (r *Reader) Guard(ctx context.Context, i int) error
- func (r *Reader) Leaves(ctx context.Context, s *Seen) ([]*zonerec.Leaf, error)
- func (r *Reader) Opened(ctx context.Context, s *Seen) ([]*zonerec.Leaf, *CheckError, error)
- 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.
func ReadRecord ¶ added in v0.3.0
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
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 ¶
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) Guard ¶ added in v0.3.0
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 ¶
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.
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