Documentation ¶
Index ¶
- Variables
- type AppResponseCallback
- type Client
- func (c *Client) AppGossip(ctx context.Context, appGossipBytes []byte) error
- func (c *Client) AppGossipSpecific(ctx context.Context, nodeIDs set.Set[ids.NodeID], appGossipBytes []byte) error
- func (c *Client) AppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], appRequestBytes []byte, ...) error
- func (c *Client) AppRequestAny(ctx context.Context, appRequestBytes []byte, onResponse AppResponseCallback) error
- func (c *Client) CrossChainAppRequest(ctx context.Context, chainID ids.ID, appRequestBytes []byte, ...) error
- type CrossChainAppResponseCallback
- type Handler
- type Router
- func (r *Router) AppGossip(ctx context.Context, nodeID ids.NodeID, gossip []byte) error
- func (r *Router) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) error
- func (r *Router) AppRequestFailed(_ context.Context, nodeID ids.NodeID, requestID uint32) error
- func (r *Router) AppResponse(_ context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
- func (r *Router) Connected(_ context.Context, nodeID ids.NodeID, _ *version.Application) error
- func (r *Router) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, ...) error
- func (r *Router) CrossChainAppRequestFailed(_ context.Context, chainID ids.ID, requestID uint32) error
- func (r *Router) CrossChainAppResponse(_ context.Context, chainID ids.ID, requestID uint32, response []byte) error
- func (r *Router) Disconnected(_ context.Context, nodeID ids.NodeID) error
- func (r *Router) RegisterAppProtocol(handlerID uint64, handler Handler) (*Client, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrAppRequestFailed = errors.New("app request failed") ErrRequestPending = errors.New("request pending") ErrNoPeers = errors.New("no peers") )
var ( ErrExistingAppProtocol = errors.New("existing app protocol") ErrUnrequestedResponse = errors.New("unrequested response") )
Functions ¶
This section is empty.
Types ¶
type AppResponseCallback ¶
AppResponseCallback is called upon receiving an AppResponse for an AppRequest issued by Client. Callers should check [err] to see whether the AppRequest failed or not.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AppGossipSpecific ¶
func (c *Client) AppGossipSpecific( ctx context.Context, nodeIDs set.Set[ids.NodeID], appGossipBytes []byte, ) error
AppGossipSpecific sends a gossip message to a predetermined set of peers.
func (*Client) AppRequest ¶
func (c *Client) AppRequest( ctx context.Context, nodeIDs set.Set[ids.NodeID], appRequestBytes []byte, onResponse AppResponseCallback, ) error
AppRequest issues an arbitrary request to a node. [onResponse] is invoked upon an error or a response.
func (*Client) AppRequestAny ¶
func (c *Client) AppRequestAny( ctx context.Context, appRequestBytes []byte, onResponse AppResponseCallback, ) error
AppRequestAny issues an AppRequest to an arbitrary node decided by Client. If a specific node needs to be requested, use AppRequest instead. See AppRequest for more docs.
func (*Client) CrossChainAppRequest ¶
func (c *Client) CrossChainAppRequest( ctx context.Context, chainID ids.ID, appRequestBytes []byte, onResponse CrossChainAppResponseCallback, ) error
CrossChainAppRequest sends a cross chain app request to another vm. [onResponse] is invoked upon an error or a response.
type CrossChainAppResponseCallback ¶
CrossChainAppResponseCallback is called upon receiving an CrossChainAppResponse for a CrossChainAppRequest issued by Client. Callers should check [err] to see whether the AppRequest failed or not.
type Handler ¶
type Handler interface { // AppGossip is called when handling an AppGossip message. AppGossip( ctx context.Context, nodeID ids.NodeID, gossipBytes []byte, ) error // AppRequest is called when handling an AppRequest message. // Returns the bytes for the response corresponding to [requestBytes] AppRequest( ctx context.Context, nodeID ids.NodeID, deadline time.Time, requestBytes []byte, ) ([]byte, error) // CrossChainAppRequest is called when handling a CrossChainAppRequest // message. // Returns the bytes for the response corresponding to [requestBytes] CrossChainAppRequest( ctx context.Context, chainID ids.ID, deadline time.Time, requestBytes []byte, ) ([]byte, error) }
Handler is the server-side logic for virtual machine application protocols.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router routes incoming application messages to the corresponding registered app handler. App messages must be made using the registered handler's corresponding Client.