zap

package
v1.23.6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package zap provides ZAP transport implementation for VM RPC.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected    = errors.New("zap: not connected")
	ErrInvalidResponse = errors.New("zap: invalid response")
)

Functions

func Dial

func Dial(ctx context.Context, addr string, config *zapwire.Config) (*zapwire.Conn, error)

Dial connects to a ZAP VM server

func NewListener

func NewListener() (net.Listener, error)

NewListener creates a new TCP listener on an available port. This is used for the ZAP handshake during VM subprocess bootstrap.

Types

type Client

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

Client implements chain.ChainVM over ZAP transport

func NewClient

func NewClient(conn *zapwire.Conn, logger log.Logger) *Client

NewClient creates a new ZAP-based VM client

func (*Client) BuildBlock added in v1.23.4

func (c *Client) BuildBlock(ctx context.Context) (block.Block, error)

BuildBlock implements chain.ChainVM

func (*Client) Close

func (c *Client) Close() error

Close closes the connection

func (*Client) Connected added in v1.23.4

func (c *Client) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error

Connected implements chain.ChainVM

func (*Client) CreateHandlers added in v1.23.4

func (c *Client) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers calls the VM's CreateHandlers and returns reverse proxy handlers

func (*Client) Disconnected added in v1.23.4

func (c *Client) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected implements chain.ChainVM

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, blkID ids.ID) (block.Block, error)

GetBlock implements chain.ChainVM

func (*Client) GetBlockIDAtHeight added in v1.23.4

func (c *Client) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements chain.ChainVM

func (*Client) HealthCheck added in v1.23.4

func (c *Client) HealthCheck(ctx context.Context) (block.HealthCheckResult, error)

HealthCheck implements chain.ChainVM

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, init block.Init) error

Initialize implements chain.ChainVM

func (*Client) LastAccepted

func (c *Client) LastAccepted(ctx context.Context) (ids.ID, error)

LastAccepted implements chain.ChainVM

func (*Client) NewHTTPHandler added in v1.23.4

func (c *Client) NewHTTPHandler(ctx context.Context) (http.Handler, error)

NewHTTPHandler implements chain.ChainVM

func (*Client) ParseBlock

func (c *Client) ParseBlock(ctx context.Context, blockBytes []byte) (block.Block, error)

ParseBlock implements chain.ChainVM

func (*Client) SetPreference

func (c *Client) SetPreference(ctx context.Context, blkID ids.ID) error

SetPreference implements chain.ChainVM

func (*Client) SetState added in v1.23.4

func (c *Client) SetState(ctx context.Context, state uint32) error

SetState implements chain.ChainVM

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) error

Shutdown implements chain.ChainVM

func (*Client) Version added in v1.23.4

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

Version implements chain.ChainVM

func (*Client) WaitForEvent added in v1.23.4

func (c *Client) WaitForEvent(ctx context.Context) (block.Message, error)

WaitForEvent implements chain.ChainVM

type Sender

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

Sender implements p2p.Sender over ZAP transport

func NewSender

func NewSender(conn *zapwire.Conn) *Sender

NewSender creates a new ZAP-based p2p.Sender

func (*Sender) SendError

func (s *Sender) SendError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error

SendError sends an error response to a previous request

func (*Sender) SendGossip

func (s *Sender) SendGossip(ctx context.Context, config p2p.SendConfig, msg []byte) error

SendGossip sends a gossip message

func (*Sender) SendRequest

func (s *Sender) SendRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, request []byte) error

SendRequest sends a request to the specified nodes

func (*Sender) SendResponse

func (s *Sender) SendResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

SendResponse sends a response to a previous request

type Server

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

Server wraps a VM and serves it over ZAP transport

func NewServer

func NewServer(v vm.VM, logger log.Logger) *Server

NewServer creates a new ZAP server for a VM

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the listener's address

func (*Server) Close

func (s *Server) Close() error

Close closes the server

func (*Server) Listen

func (s *Server) Listen(addr string, config *zapwire.Config) error

Listen starts listening on the specified address

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts serving requests

Jump to

Keyboard shortcuts

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