Documentation
¶
Overview ¶
Package gp2papi manages the handlers for nodes that choose to serve public gcosmos (Gordian-Cosmos, not plain Cosmos) APIs over libp2p.
Index ¶
- type CatchupClient
- func (c *CatchupClient) AddPeer(ctx context.Context, p libp2ppeer.ID) (ok bool)
- func (c *CatchupClient) PauseFetching(ctx context.Context) (ok bool)
- func (c *CatchupClient) RemovePeer(ctx context.Context, p libp2ppeer.ID) (ok bool)
- func (c *CatchupClient) ResumeFetching(ctx context.Context, startHeight, stopHeight uint64) (ok bool)
- func (c *CatchupClient) Wait()
- type CatchupClientConfig
- type DataHost
- type FullBlockResult
- type JSONResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatchupClient ¶
type CatchupClient struct {
// contains filtered or unexported fields
}
CatchupClient manages fetching committed headers, and optionally their block data, from peers when the engine indicates that the mirror subsystem is lagging behind the rest of the network.
func NewCatchupClient ¶
func NewCatchupClient( ctx context.Context, log *slog.Logger, cfg CatchupClientConfig, ) *CatchupClient
func (*CatchupClient) AddPeer ¶
func (c *CatchupClient) AddPeer(ctx context.Context, p libp2ppeer.ID) (ok bool)
AddPeer requests to add the given peer ID as a candidate peer for fetching committed headers and block data.
func (*CatchupClient) PauseFetching ¶
func (c *CatchupClient) PauseFetching(ctx context.Context) (ok bool)
PauseFetching requests that outstanding committed header fetches are interrupted.
func (*CatchupClient) RemovePeer ¶
func (c *CatchupClient) RemovePeer(ctx context.Context, p libp2ppeer.ID) (ok bool)
RemovePeer requests to remove the given peer ID as a candidate peer for fetching committed headers and block data.
func (*CatchupClient) ResumeFetching ¶
func (c *CatchupClient) ResumeFetching( ctx context.Context, startHeight, stopHeight uint64, ) (ok bool)
ResumeFetching requests that committed header and block data fetches are restarted, or it can indicate that the start and stop height values have changed.
func (*CatchupClient) Wait ¶
func (c *CatchupClient) Wait()
Wait blocks until all of c's background work is completed. Initiate a shutdown by canceling the context passed to NewCatchupClient.
type CatchupClientConfig ¶
type CatchupClientConfig struct {
// The host from which we will open libp2p streams to other hosts.
Host libp2phost.Host
// How to unmarshal Gordian consensus messages.
Unmarshaler tmcodec.Unmarshaler
// How to decode SDK transactions encoded in block data.
TxDecoder transaction.Codec[transaction.Tx]
// Side channel for block data requests,
// so that the driver's finalization handler
// can be notified when block data is available.
RequestCache *gsbd.RequestCache
// Where to send the replayed headers.
// This same channel should be passed to the
// [tmengine.WithReplayedHeaderRequestChannel] option.
ReplayedHeadersOut chan<- tmelink.ReplayedHeaderRequest
}
CatchupClientConfig is the configuration for a CatchupClient.
type DataHost ¶
type DataHost struct {
// contains filtered or unexported fields
}
DataHost provides header and block data over libp2p.
It is currently coupled to JSON encoding (see the tm/tmcodec/tmjson package). The codec interfaces will need updated to handle wrapping the value or an error, in order to decouple this from JSON.
func NewDataHost ¶
func NewDataHost( ctx context.Context, log *slog.Logger, host libp2phost.Host, chs tmstore.CommittedHeaderStore, bds gcstore.BlockDataStore, codec tmcodec.MarshalCodec, ) *DataHost
type FullBlockResult ¶
type FullBlockResult struct {
Header json.RawMessage
BlockData []byte
}
FullBlockResult is the JSON representation of a header and the associated block data.
This will always be set as the Result field on a JSONResult. Use a [tmjson.MarshalCodec] to decode the Header JSON.
The BlockData field must be parsed according to the rules in the gsbd package (which need to be extracted somewhere else).
type JSONResult ¶
type JSONResult struct {
Result json.RawMessage `json:",omitempty"`
Err string `json:",omitempty"`
}
JSONResult is currently used to wrap results from gp2papi calls. It is likely to be superseded by something else soon.