Documentation
¶
Index ¶
Constants ¶
const MaxRequestLength = 900
MaxRequestLength is the protocol cap on tipsets per request.
const ProtocolID protocol.ID = "/fil/chain/xchg/0.0.1"
ProtocolID is the libp2p protocol ID for Filecoin ChainExchange.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a ChainExchange requester bound to a libp2p host.
func NewClient ¶
NewClient constructs a ChainExchange client on h. Register() is NOT required; the client only opens outbound streams.
func (*Client) ClientStats ¶
func (c *Client) ClientStats() ClientStats
ClientStats returns a snapshot.
func (*Client) FetchTipsetChain ¶
func (c *Client) FetchTipsetChain(ctx context.Context, head []cid.Cid, length int) ([][]*ltypes.BlockHeader, error)
FetchTipsetChain requests up to length tipsets of HEADERS starting at the tipset whose block CIDs are head, walking parent-ward. The result is ordered as received: index 0 = the head tipset, increasing index = older. Every header is CID-verified and every level is verified to be the parent set of the level above; the first level must match head exactly. Returns at least one tipset on success (partial responses are legal and returned as-is).
func (*Client) SetPreferredPeers ¶
SetPreferredPeers wires a provider of first-choice peers (trusted floor / quorum peers). Optional.
type ClientStats ¶
type ClientStats struct {
Requests uint64 `json:"requests"`
Succeeded uint64 `json:"succeeded"`
Failed uint64 `json:"failed"`
PeerTries uint64 `json:"peer_tries"`
}
ClientStats reports observable activity for the dashboard.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the ChainExchange responder bound to a libp2p host.
func NewService ¶
NewService constructs a Service. Caller must call Register() to attach the stream handler.
func (*Service) Register ¶
func (s *Service) Register()
Register attaches the ChainExchange stream handler to the host. Idempotent.
type Source ¶
Source is the read surface a ChainExchange server needs from the local header store. Small enough that store.Store satisfies it out of the box (see chain/header/store/store.go), and small enough that an in-memory test source is trivial to write.
GetTipSet MUST return a *TipSet whose blocks match the given key exactly, or an error. Callers use ErrNotFound-style errors (or any non-nil error) to mean "not served"; the server responds with statusNotFound in that case.