Documentation
¶
Overview ¶
Package consensus provides a Quasar consensus adapter for pubsub.
Quasar uses two independent cryptographic layers (BLS + PQ), each verifiable in parallel. All inter-node communication uses ZAP (Zero-copy Application Protocol) — no dependency on github.com/luxfi/p2p.
Index ¶
- Constants
- type Config
- type FinalizedOp
- type Op
- type OpType
- type Quasar
- func (q *Quasar) ConnectPeer(addr string) error
- func (q *Quasar) IsFinalized(hash string) bool
- func (q *Quasar) ReceiveVote(hash string, validatorID string, sig *QuasarSignature) bool
- func (q *Quasar) Start(ctx context.Context) error
- func (q *Quasar) Status() Status
- func (q *Quasar) Stop()
- func (q *Quasar) Submit(ctx context.Context, op Op) (string, error)
- type QuasarConsensus
- type QuasarSignature
- type Status
Constants ¶
const ( OpPropose uint16 = 0x20 // broadcast pending op for signing OpVote uint16 = 0x21 // QuasarSignature back to proposer OpFinalized uint16 = 0x22 // announce PQ finality to all peers OpSyncReq uint16 = 0x23 // request missed finalized ops OpSyncResp uint16 = 0x24 // return finalized ops )
ZAP opcodes for consensus P2P messages (0x20 range).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Threshold int
ValidatorIDs []string
ValidatorID string
MaxFinalized int
// ZAP transport
ZAPPort int
ZAPPeers []string
ZAPDiscover bool
// Store enables consensus state persistence.
Store *store.Store
Logger *slog.Logger
}
Config configures the Quasar consensus adapter.
type FinalizedOp ¶
type FinalizedOp struct {
Hash string `json:"hash"`
Height uint64 `json:"height"`
FinalizedAt int64 `json:"finalized_at"`
}
FinalizedOp is an operation that achieved PQ finality.
type Op ¶
type Op struct {
Type OpType `json:"type"`
Stream string `json:"stream"`
Subject string `json:"subject,omitempty"`
Payload []byte `json:"payload,omitempty"`
Timestamp int64 `json:"ts"` // set automatically on submit
}
Op represents a stream operation submitted for PQ consensus.
type Quasar ¶
type Quasar struct {
// contains filtered or unexported fields
}
Quasar wraps the Lux consensus signer for pubsub stream operations. All P2P communication uses ZAP.
func (*Quasar) ConnectPeer ¶
ConnectPeer adds a static peer by address (host:port).
func (*Quasar) IsFinalized ¶
IsFinalized checks whether an operation has achieved PQ finality.
func (*Quasar) ReceiveVote ¶
func (q *Quasar) ReceiveVote(hash string, validatorID string, sig *QuasarSignature) bool
ReceiveVote records a validator's signature for a pending operation.
type QuasarConsensus ¶
Type aliases to the upstream consensus quasar primitives.
type QuasarSignature ¶
Type aliases to the upstream consensus quasar primitives.
type Status ¶
type Status struct {
Enabled bool `json:"enabled"`
Height uint64 `json:"height"`
Pending int `json:"pending"`
Finalized int `json:"finalized"`
Validators int `json:"validators"`
Threshold int `json:"threshold"`
Peers []string `json:"peers"`
NodeID string `json:"node_id"`
}
Status reports the current state of the Quasar consensus layer.