glif

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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultURL = "https://api.node.glif.io/rpc/v1"

DefaultURL is the canonical Glif node RPC.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Glif JSON-RPC client. Goroutine-safe.

func New

func New(url string, timeout time.Duration) *Client

New returns a Client. Empty url defaults to DefaultURL.

func (*Client) BlockDelaySecs

func (c *Client) BlockDelaySecs(ctx context.Context) (uint64, error)

BlockDelaySecs queries Filecoin.Version and returns the BlockDelay field (block cadence in seconds). Mainnet = 30, calibration = 30, curio-fork docker devnet = 4. Devnet setups may customize this via the `//go:build 2k` variant, so we bind it at devnet-init time.

func (*Client) EthChainID

func (c *Client) EthChainID(ctx context.Context) (uint64, error)

EthChainID queries eth_chainId and returns the decimal chain identifier. The devnet-init path uses this to bind the devnet's EIP-155 chain ID into the Lantern config so `eth_chainId` + `net_version` on the daemon return the same value clients pass to `docker compose up` (Curio's devnet defaults to 31415926 / 0x1df5e76).

func (*Client) FetchBlock

func (c *Client) FetchBlock(ctx context.Context, k cid.Cid) (*types.BlockHeader, error)

FetchBlock fetches a single BlockHeader by CID. We use ChainReadObj (which returns the raw CBOR bytes) and decode locally. This avoids the JSON serialisation roundtrip in ChainGetBlock and is byte-stable.

func (*Client) FetchGenesis

func (c *Client) FetchGenesis(ctx context.Context) (cid.Cid, error)

FetchGenesis queries Filecoin.ChainGetGenesis and returns block 0's CID. The devnet-init path uses this to bind the local devnet's genesis into the Lantern config so /fil/hello/1.0.0 identifies the correct chain.

func (*Client) FetchHead

func (c *Client) FetchHead(ctx context.Context) (*Head, error)

FetchHead queries Filecoin.ChainHead.

func (*Client) FetchTipsetByHeight

func (c *Client) FetchTipsetByHeight(ctx context.Context, h abi.ChainEpoch) (*Head, error)

FetchTipsetByHeight queries Filecoin.ChainGetTipSetByHeight at the given epoch, returning the block CIDs and (parent-state-root, parent-weight) of the first block in the tipset. Caller is responsible for fetching each block CID via Get(...) and verifying.

func (*Client) Get

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

Get implements state/hamt.BlockGetter via Filecoin.ChainReadObj.

func (*Client) HeadEpoch

func (c *Client) HeadEpoch(ctx context.Context) (abi.ChainEpoch, error)

HeadEpoch satisfies header/store.RPCSource.

func (*Client) MpoolPush

func (c *Client) MpoolPush(ctx context.Context, sm *types.SignedMessage) (cid.Cid, error)

MpoolPush pushes a signed message via the upstream lotus RPC's Filecoin.MpoolPush method. Used by devnet mode (`--network devnet`) as the send-path sink for the local mpool: a single-node docker devnet can't form a gossipsub mesh, so the pubsub topic never propagates. The devnet's lotus accepts signed messages directly via this JSON-RPC method and does its own inclusion.

Trust posture: unchanged from #122. Devnet is single-source by design (operator owns the devnet). This method is NOT used on mainnet/ calibration; the gossipsub publisher path continues to be the only producer of network traffic there.

func (*Client) StateActorCodeCIDs

func (c *Client) StateActorCodeCIDs(ctx context.Context, networkVersion uint64) (map[string]cid.Cid, error)

StateActorCodeCIDs queries Filecoin.StateActorCodeCIDs for the given network version and returns the actor-name -> code-CID map. A custom devnet (debug-compiled builtin-actors) ships code CIDs that are in no released bundle; recording them lets Lantern's actor registry decode devnet state that would otherwise be "unknown code CID".

func (*Client) StateNetworkName

func (c *Client) StateNetworkName(ctx context.Context) (string, error)

StateNetworkName queries Filecoin.StateNetworkName so a Lantern client pointed at an unknown network (devnet, forkline, ...) can discover the wire-name string libp2p protocols expect (gossipsub topics, DHT prefix).

func (*Client) StateNetworkVersion

func (c *Client) StateNetworkVersion(ctx context.Context) (uint64, error)

StateNetworkVersion queries Filecoin.StateNetworkVersion at the current head and returns the network version. The devnet-init path records it so the daemon can map the devnet's actor code CIDs to the right go-state- types actor-version decoders.

func (*Client) TipsetCIDsByHeight

func (c *Client) TipsetCIDsByHeight(ctx context.Context, h abi.ChainEpoch) ([]cid.Cid, error)

TipsetCIDsByHeight satisfies header/store.RPCSource.

type Head struct {
	Epoch                 abi.ChainEpoch
	TipSetKey             types.TipSetKey
	StateRoot             cid.Cid
	ParentWeight          big.Int
	ParentMessageReceipts cid.Cid
}

Head returns the current tipset's (epoch, key, stateRoot, parentWeight). The shape mirrors Lotus' api.TipSet so we can build a Lantern TrustedRoot from it.

Jump to

Keyboard shortcuts

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