mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- Remove unused packages: engine/dag/{getter,bootstrap,vertex/vertexmock},
engine/pq/{bootstrap,block}, core/{tracker,verify}
- Add sync.RWMutex to protocol/wave for thread-safe map access
- Increase engine/dag test coverage from 11.7% to 98.3%
- Add comprehensive tests for DAG consensus, vertex, and engine
- All 27 packages pass tests, 16 at 100% coverage
68 lines
1.3 KiB
Go
68 lines
1.3 KiB
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// Message represents a network message
|
|
type Message interface {
|
|
NodeID() ids.NodeID
|
|
Op() Op
|
|
Get(Field) interface{}
|
|
Bytes() []byte
|
|
BytesSavedCompression() int
|
|
AddRef()
|
|
DecRef()
|
|
IsProposal() bool
|
|
}
|
|
|
|
// Op represents a message operation type
|
|
type Op byte
|
|
|
|
const (
|
|
// GetAcceptedFrontier gets accepted frontier
|
|
GetAcceptedFrontier Op = iota
|
|
// AcceptedFrontier is accepted frontier response
|
|
AcceptedFrontier
|
|
// GetAccepted gets accepted
|
|
GetAccepted
|
|
// Accepted is accepted response
|
|
Accepted
|
|
// Get gets an item
|
|
Get
|
|
// Put puts an item
|
|
Put
|
|
// PushQuery pushes a query
|
|
PushQuery
|
|
// PullQuery pulls a query
|
|
PullQuery
|
|
// Chits is chits response
|
|
Chits
|
|
)
|
|
|
|
// Field represents a message field
|
|
type Field byte
|
|
|
|
// InboundHandler handles inbound messages
|
|
type InboundHandler interface {
|
|
HandleInbound(context.Context, Message) error
|
|
}
|
|
|
|
// ExternalHandler handles messages from external chains
|
|
type ExternalHandler interface {
|
|
Connected(nodeID ids.NodeID, nodeVersion interface{}, subnetID ids.ID)
|
|
Disconnected(nodeID ids.NodeID)
|
|
HandleInbound(context.Context, Message) error
|
|
}
|
|
|
|
// HealthConfig configures health checks
|
|
type HealthConfig struct {
|
|
Enabled bool
|
|
Interval time.Duration
|
|
Timeout time.Duration
|
|
MaxOutstandingChecks int
|
|
}
|