hsync

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 9 Imported by: 0

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

View Source
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

func NewClient(endpoints []string, timeout time.Duration) *Client

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

func (c *Client) Get(ctx context.Context, k cid.Cid) ([]byte, error)

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

func (c *Client) GetStateHead(ctx context.Context) (*StateHead, error)

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

func (c *Client) SetHTTPClient(hc *http.Client)

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

func (c *Client) SetRetries(n int)

SetRetries overrides the per-endpoint retry budget.

type StateHead

type StateHead struct {
	Epoch        int64    `json:"epoch"`
	TipsetKey    []string `json:"tipsetKey"`
	StateRoot    string   `json:"stateRoot"`
	ParentWeight string   `json:"parentWeight"`
}

StateHead is the JSON returned by GET /state/root.

Jump to

Keyboard shortcuts

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