Documentation
¶
Overview ¶
Package hsync is Lantern's HTTPS gateway client.
A "Lantern gateway" is a thin proxy node that translates Lantern's `GET /block/{cid}` calls into upstream Bitswap fetches or Filecoin RPC reads. The client never trusts the gateway's bytes; every fetched block is re-hashed against the requested CID before insertion into the cache.
See cmd/lantern-gateway for the server side.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("block not found in any gateway")
ErrNotFound is returned when no gateway has the requested CID.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fetches IPLD blocks from one or more Lantern gateways. Multiple gateways are tried sequentially; the first successful CID-matching response wins. Each endpoint is retried up to `retries` times with exponential backoff on transient errors (DNS, TLS handshake, connection reset, 5xx, 429).
func NewClient ¶
NewClient configures a Client. `endpoints` is a list of gateway base URLs (no trailing slash); the canonical Lantern endpoint is `https://gateway.lantern.reiers.io`. `timeout` is per-request.
func (*Client) Get ¶
Get fetches the block bytes for `c` from the first gateway that returns a 200 with a CID-matching body. Returns ErrNotFound if every gateway returns 404; other errors are wrapped and returned from the first failure.
func (*Client) GetStateHead ¶
GetStateHead probes /state/root on the first gateway. Useful for cold- start: Lantern needs a starting state-root CID before any other fetch.
func (*Client) SetHTTPClient ¶
HTTPClient lets callers swap in a custom *http.Client (e.g. with a custom dialer for DNS workarounds). Optional; default is set in NewClient.
func (*Client) SetRetries ¶
SetRetries overrides the per-endpoint retry budget.