Documentation
¶
Overview ¶
Package chainclient is a chain tracker backed by an overlay-bridge header read API.
It exists for GO consumers of the same header store that an engine reads: a command-line client verifying proofs, or a Go host passing it as its chain tracker. It imports only the SDK on purpose, so taking it costs a consumer nothing but this one small dependency.
A TypeScript host cannot import it at all and does not need to: it reaches the same store over HTTP through the chaintracks shape the same API serves.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Base is the read API's ORIGIN, without a version segment, for example
// http://headers.example:9178. The routes are appended here.
//
// It used to mean the origin WITH the version on it, and the two other
// clients written against this same service took it without. One config
// string with two meanings, and the symptom of getting it wrong is a 404
// from a service that is up. A base that still carries a trailing /v1 is
// accepted and normalised rather than 404ing, because operators copy these
// values between unit files.
Base string
HTTP *http.Client
}
Client speaks the bridge's native /v1 shape.
func (*Client) CurrentHeight ¶
CurrentHeight reports the tip height the bridge has reached.
func (*Client) IsValidRootForHeight ¶
func (c *Client) IsValidRootForHeight(ctx context.Context, root *chainhash.Hash, height uint32) (bool, error)
IsValidRootForHeight reports whether root is the merkle root at height.
A height the store does not hold answers 404, which is reported as "not valid" with no error: it means the proof cannot be checked yet, not that something is broken.
⚠ DO NOT DRIVE ENGINE REORG HANDLING AGAINST THIS TRACKER AS IT STANDS. The overlay engine's isProvenAnchorStale treats isValidRootForHeight == false as STALE and evicts, and this method returns false for a 404 that means "the store does not hold that height", not "that root is wrong". Wiring handleReorg or revalidateRecentAnchors to this today would therefore destroy live state for every height the store has not yet received, which on a host anchored below the chain tip is most of them. Fix the 404 semantics first: the two cases need to be distinguishable to a caller that evicts on the answer.