mirror of
https://github.com/luxfi/warp.git
synced 2026-10-30 15:13:04 +00:00
- Add dependency on github.com/luxfi/p2p v1.4.4 - warp.Error is now an alias for p2p.Error - warp.Sender is now an alias for p2p.Sender - warp.SendConfig is now an alias for p2p.SendConfig - Re-export standard errors from p2p (ErrUnexpected, etc) - Update Handler to use p2p.Error in signatures
27 lines
1023 B
Go
27 lines
1023 B
Go
// Copyright (C) 2019-2025, Lux Industries Inc All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package warp
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/p2p"
|
|
)
|
|
|
|
// Handler handles messages between nodes.
|
|
// This is the primary interface for receiving cross-node messages used by VMs.
|
|
// For simple request/response handlers, use p2p.Handler directly.
|
|
type Handler interface {
|
|
// Request handles an incoming request and returns a response or error
|
|
Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, msg []byte) ([]byte, *p2p.Error)
|
|
// Response handles an incoming response to a previous request
|
|
Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, msg []byte) error
|
|
// Gossip handles an incoming gossip message
|
|
Gossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
|
|
// RequestFailed is called when a request fails
|
|
RequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, err *p2p.Error) error
|
|
}
|