Documentation
¶
Overview ¶
Package network provides peer-to-peer networking and Warp messaging for the DEX VM.
Index ¶
- Variables
- type Handler
- func (h *Handler) Gossip(msg *Message, gossipFunc func([]byte) error) error
- func (h *Handler) HandleCrossChainRequest(ctx context.Context, sourceChainID ids.ID, requestID uint32, ...) ([]byte, error)
- func (h *Handler) HandleCrossChainResponse(ctx context.Context, sourceChainID ids.ID, requestID uint32, ...) error
- func (h *Handler) HandleGossip(ctx context.Context, nodeID ids.NodeID, msgBytes []byte) error
- func (h *Handler) HandleRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) ([]byte, error)
- func (h *Handler) HandleResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, responseBytes []byte) error
- func (h *Handler) SendRequest(ctx context.Context, nodeID ids.NodeID, msg *Message, timeout time.Duration, ...) (*Message, error)
- func (h *Handler) SetOrderHandler(handler func(*Message) error)
- func (h *Handler) SetSyncHandler(handler func(*Message) error)
- func (h *Handler) SetTradeHandler(handler func(*Message) error)
- func (h *Handler) SetWarpHandler(handler func(*Message) error)
- func (h *Handler) Stats() (sent, received, bytesIn, bytesOut uint64)
- type Message
- type MessageType
- type WarpManager
- func (w *WarpManager) AddTrustedChain(chainID ids.ID)
- func (w *WarpManager) CreateOutgoingMessage(destChain ids.ID, payload []byte, deadline time.Duration) *WarpMessage
- func (w *WarpManager) GetPendingMessage(id ids.ID) (*WarpMessage, bool)
- func (w *WarpManager) IsTrustedChain(chainID ids.ID) bool
- func (w *WarpManager) ProcessIncomingMessage(msg *WarpMessage) error
- func (w *WarpManager) RemovePendingMessage(id ids.ID)
- func (w *WarpManager) RemoveTrustedChain(chainID ids.ID)
- type WarpMessage
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles network messages for the DEX VM.
func NewHandler ¶
NewHandler creates a new network handler.
func (*Handler) HandleCrossChainRequest ¶
func (h *Handler) HandleCrossChainRequest( ctx context.Context, sourceChainID ids.ID, requestID uint32, deadline time.Time, msgBytes []byte, ) ([]byte, error)
HandleCrossChainRequest handles a cross-chain request via Warp.
func (*Handler) HandleCrossChainResponse ¶
func (h *Handler) HandleCrossChainResponse( ctx context.Context, sourceChainID ids.ID, requestID uint32, responseBytes []byte, ) error
HandleCrossChainResponse handles a cross-chain response.
func (*Handler) HandleGossip ¶
HandleGossip handles an incoming gossip message.
func (*Handler) HandleRequest ¶
func (h *Handler) HandleRequest( ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, msgBytes []byte, ) ([]byte, error)
HandleRequest handles an incoming request message.
func (*Handler) HandleResponse ¶
func (h *Handler) HandleResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, responseBytes []byte) error
HandleResponse handles a response to a previously sent request.
func (*Handler) SendRequest ¶
func (h *Handler) SendRequest( ctx context.Context, nodeID ids.NodeID, msg *Message, timeout time.Duration, sendFunc func(ids.NodeID, uint32, []byte) error, ) (*Message, error)
SendRequest sends a request and waits for a response.
func (*Handler) SetOrderHandler ¶
SetOrderHandler sets the handler for order gossip messages.
func (*Handler) SetSyncHandler ¶
SetSyncHandler sets the handler for sync messages.
func (*Handler) SetTradeHandler ¶
SetTradeHandler sets the handler for trade gossip messages.
func (*Handler) SetWarpHandler ¶
SetWarpHandler sets the handler for Warp messages.
type Message ¶
type Message struct {
Type MessageType
RequestID uint32
Payload []byte
ChainID ids.ID // For cross-chain messages
Sender ids.NodeID
Timestamp int64
}
Message represents a network message.
func DecodeMessage ¶
DecodeMessage decodes a message from bytes.
type MessageType ¶
type MessageType uint8
MessageType represents the type of network message.
const ( MsgOrderGossip MessageType = iota MsgTradeGossip MsgOrderbookSync MsgPoolSync MsgCrossChainSwap MsgCrossChainTransfer MsgWarpMessage )
func (MessageType) String ¶
func (t MessageType) String() string
type WarpManager ¶
type WarpManager struct {
// contains filtered or unexported fields
}
WarpManager manages cross-chain Warp messaging.
func NewWarpManager ¶
NewWarpManager creates a new Warp manager.
func (*WarpManager) AddTrustedChain ¶
func (w *WarpManager) AddTrustedChain(chainID ids.ID)
AddTrustedChain adds a chain to the trusted list.
func (*WarpManager) CreateOutgoingMessage ¶
func (w *WarpManager) CreateOutgoingMessage( destChain ids.ID, payload []byte, deadline time.Duration, ) *WarpMessage
CreateOutgoingMessage creates a Warp message to send to another chain.
func (*WarpManager) GetPendingMessage ¶
func (w *WarpManager) GetPendingMessage(id ids.ID) (*WarpMessage, bool)
GetPendingMessage returns a pending Warp message.
func (*WarpManager) IsTrustedChain ¶
func (w *WarpManager) IsTrustedChain(chainID ids.ID) bool
IsTrustedChain returns true if the chain is trusted for cross-chain messaging.
func (*WarpManager) ProcessIncomingMessage ¶
func (w *WarpManager) ProcessIncomingMessage(msg *WarpMessage) error
ProcessIncomingMessage processes an incoming Warp message.
func (*WarpManager) RemovePendingMessage ¶
func (w *WarpManager) RemovePendingMessage(id ids.ID)
RemovePendingMessage removes a pending Warp message.
func (*WarpManager) RemoveTrustedChain ¶
func (w *WarpManager) RemoveTrustedChain(chainID ids.ID)
RemoveTrustedChain removes a chain from the trusted list.