mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
Appends seven ops above the existing op-space — GetStateSummaryFrontier, StateSummaryFrontier, GetAcceptedStateSummary, AcceptedStateSummary, and the AppRequest/AppResponse/AppError EVM fetch transport — so a node can route the messages a pruned peer needs to re-fetch state instead of dropping them at the chain router. Additive: every pre-existing wire value is unchanged. This is the routing layer for state sync; the handler methods and sync-client driver that consume these ops land on top. Co-authored-by: Hanzo Dev <[email protected]>
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/luxfi/consensus/core/router"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// Handler handles network messages
|
|
type Handler interface {
|
|
// HandleInbound handles inbound messages
|
|
HandleInbound(context.Context, Message) error
|
|
|
|
// HandleOutbound handles outbound messages
|
|
HandleOutbound(context.Context, Message) error
|
|
|
|
// Connected handles node connection
|
|
Connected(context.Context, ids.NodeID) error
|
|
|
|
// Disconnected handles node disconnection
|
|
Disconnected(context.Context, ids.NodeID) error
|
|
}
|
|
|
|
// Message represents a network message
|
|
type Message struct {
|
|
NodeID ids.NodeID
|
|
RequestID uint32
|
|
Op Op
|
|
Message []byte
|
|
}
|
|
|
|
// Op re-exports from core/router for consistency
|
|
type Op = router.Op
|
|
|
|
// Op constants re-exported from core/router
|
|
const (
|
|
GetAcceptedFrontier = router.GetAcceptedFrontier
|
|
AcceptedFrontier = router.AcceptedFrontier
|
|
GetAccepted = router.GetAccepted
|
|
Accepted = router.Accepted
|
|
Get = router.Get
|
|
Put = router.Put
|
|
PushQuery = router.PushQuery
|
|
PullQuery = router.PullQuery
|
|
Vote = router.Vote
|
|
GetContext = router.GetContext
|
|
Context = router.Context
|
|
Gossip = router.Gossip
|
|
|
|
// State-sync ops (frontier round + EVM App transport) — see core/router.
|
|
GetStateSummaryFrontier = router.GetStateSummaryFrontier
|
|
StateSummaryFrontier = router.StateSummaryFrontier
|
|
GetAcceptedStateSummary = router.GetAcceptedStateSummary
|
|
AcceptedStateSummary = router.AcceptedStateSummary
|
|
AppRequest = router.AppRequest
|
|
AppResponse = router.AppResponse
|
|
AppError = router.AppError
|
|
)
|