Files
base/plugins/zap/config.go
zeekay 23121474a8 infra: standardize ZAP duplex port to 9999
ZAP binary protocol duplex RPC standardizes on :9999 across every
service. Lux validator staking/RPC ports (9630/9631 mainnet, 9650/9651
devnet) are unchanged — those are luxd network protocol ports, not ZAP.

One ZAP port everywhere (was a mix of 9651/9652/9653/9633/9900).
2026-04-25 15:35:01 -07:00

47 lines
1.0 KiB
Go

// Package zap provides a ZAP binary protocol transport for Hanzo Base.
//
// Instead of HTTP/JSON, clients can communicate with Base using the
// ZAP zero-copy binary protocol for significantly lower latency and
// memory usage.
package zap
import (
"fmt"
"os"
)
// Config for the ZAP transport plugin.
type Config struct {
// Port to listen on for ZAP connections (default 9999).
Port int
// ServiceType for mDNS discovery (default "_hanzo-base._tcp").
ServiceType string
// NodeID for ZAP peer identification (default hostname-based).
NodeID string
// Enabled controls whether the ZAP listener starts (default true).
Enabled bool
}
// DefaultConfig returns a Config with sensible defaults.
func DefaultConfig() Config {
nodeID, _ := os.Hostname()
if nodeID == "" {
nodeID = "base-node"
}
port := 9999
if p := os.Getenv("ZAP_PORT"); p != "" {
fmt.Sscanf(p, "%d", &port)
}
return Config{
Port: port,
ServiceType: "_hanzo-base._tcp",
NodeID: nodeID,
Enabled: os.Getenv("ZAP_DISABLED") != "true",
}
}