models

package
v0.3.88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SyncModeFast uses --start-in-epoch: fast bootstrap from the network's
	// latest epoch. The default and right choice for most validators.
	SyncModeFast = "fast"
	// SyncModeFullDB downloads the official Klever FullNode DB snapshot before
	// first start — a full archival node (e.g. for indexers like Klever-Radar).
	SyncModeFullDB = "full-db"
	// SyncModeGenesis syncs from epoch 0 with no flag. Slow, complete history.
	SyncModeGenesis = "genesis"
)

Provisioning sync modes.

View Source
const CapabilityConfigPreview = "config-preview"

CapabilityConfigPreview signals that the agent understands config.preview (compare current vs. new configs) and the "keep" list on config.upgrade. The dashboard only offers the keep/overwrite dialog for agents that advertise it; older agents keep the plain replace-everything config upgrade.

View Source
const CapabilityHTTPUpdate = "http-update"

CapabilityHTTPUpdate signals that the agent can fetch its update binary over a separate HTTP(S) request instead of receiving it base64-encoded inside the WebSocket command. The dashboard picks the transport per agent based on this, so old agents (which don't send it) keep getting the base64 payload — the change is fully backward compatible in both directions.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentInfo

type AgentInfo struct {
	Version      string   `json:"version"`
	OS           string   `json:"os"`
	Hostname     string   `json:"hostname"`
	IP           string   `json:"ip"`
	PublicIP     string   `json:"public_ip,omitempty"`
	Capabilities []string `json:"capabilities,omitempty"`
}

AgentInfo is sent by the agent on first connect.

type CommandResult

type CommandResult struct {
	CommandID string `json:"command_id"`
	Success   bool   `json:"success"`
	Output    string `json:"output,omitempty"`
	Error     string `json:"error,omitempty"`
}

CommandResult is sent by the agent after executing a command.

type DBResetProgress added in v0.3.85

type DBResetProgress struct {
	ContainerName string `json:"container_name"`
	Phase         string `json:"phase"` // "stopping", "clearing", "starting", "done", "failed"
	Message       string `json:"message,omitempty"`
	Error         string `json:"error,omitempty"`
}

DBResetProgress is sent during a fast-reset to report status. Emitted as a "node.reset-db.progress" event. Unlike a restore there is no download, so the phases are few and it completes in seconds before the node syncs on its own.

type DBRestoreProgress added in v0.3.78

type DBRestoreProgress struct {
	JobID         string `json:"job_id"`
	ContainerName string `json:"container_name"`
	Phase         string `json:"phase"`   // "preflight", "stopping", "downloading", "extracting", "permissions", "starting", "done", "failed"
	Percent       int    `json:"percent"` // 0-100 for the download phase; best-effort otherwise
	Message       string `json:"message,omitempty"`
	Error         string `json:"error,omitempty"`
}

DBRestoreProgress is sent during a chain-DB restore to report status. It is emitted as an "node.restore-db.progress" event so the dashboard can show a live bar for a download that can run from minutes to over an hour.

type DiscoveredNode

type DiscoveredNode struct {
	ContainerID     string  `json:"container_id"`
	ContainerName   string  `json:"container_name"`
	Status          string  `json:"status"`
	RestAPIPort     int     `json:"rest_api_port"`
	DisplayName     string  `json:"display_name,omitempty"`
	RedundancyLevel int     `json:"redundancy_level"`
	DockerImageTag  string  `json:"docker_image_tag,omitempty"`
	DataDirectory   string  `json:"data_directory,omitempty"`
	BLSPublicKey    string  `json:"bls_public_key,omitempty"`
	CPUPercent      float64 `json:"cpu_percent"`
	MemUsed         uint64  `json:"mem_used"`
	MemLimit        uint64  `json:"mem_limit"`
	MemPercent      float64 `json:"mem_percent"`
}

DiscoveredNode is a node found during agent auto-discovery.

type DiscoveryReport

type DiscoveryReport struct {
	Nodes []DiscoveredNode `json:"nodes"`
}

DiscoveryReport is sent by the agent after scanning for Klever nodes.

type HeartbeatPayload

type HeartbeatPayload struct {
	Timestamp int64          `json:"timestamp"`
	Metrics   *SystemMetrics `json:"metrics,omitempty"`
	PublicIP  string         `json:"public_ip,omitempty"`
}

HeartbeatPayload is sent periodically by the agent.

type Message

type Message struct {
	ID        string `json:"id"`
	Type      string `json:"type"` // "command", "response", "event", "stream"
	Action    string `json:"action"`
	Payload   any    `json:"payload,omitempty"`
	Timestamp int64  `json:"timestamp"`
}

Message is the WebSocket message envelope between dashboard and agents.

type Node

type Node struct {
	ID              string         `json:"id"`
	ServerID        string         `json:"server_id"`
	Name            string         `json:"name"`             // e.g., "node1"
	ContainerName   string         `json:"container_name"`   // e.g., "klever-node1"
	NodeType        string         `json:"node_type"`        // "validator", "observer"
	RedundancyLevel int            `json:"redundancy_level"` // 0 = active, 1 = fallback
	RestAPIPort     int            `json:"rest_api_port"`
	DisplayName     string         `json:"display_name,omitempty"`
	DockerImageTag  string         `json:"docker_image_tag,omitempty"`
	DataDirectory   string         `json:"data_directory"`
	BLSPublicKey    string         `json:"bls_public_key,omitempty"`
	Status          string         `json:"status"` // "running", "stopped", "syncing", "error"
	CreatedAt       int64          `json:"created_at"`
	UpdatedAt       int64          `json:"updated_at"`
	Metadata        map[string]any `json:"metadata,omitempty"`
}

Node represents a Klever node managed by an agent.

type NodeMetricsEvent

type NodeMetricsEvent struct {
	NodeID      string         `json:"node_id"`
	ServerID    string         `json:"server_id"`
	Metrics     map[string]any `json:"metrics,omitempty"`
	Error       string         `json:"error,omitempty"`
	CollectedAt int64          `json:"collected_at"`
}

NodeMetricsEvent contains metrics polled from a single Klever node's /node/status endpoint.

type NodeNonceStallEvent

type NodeNonceStallEvent struct {
	NodeID        string  `json:"node_id"`
	ServerID      string  `json:"server_id"`
	StuckNonce    uint64  `json:"stuck_nonce"`
	StallDuration float64 `json:"stall_duration_seconds"`
	DetectedAt    int64   `json:"detected_at"`
}

NodeNonceStallEvent is sent when a node's nonce stops incrementing.

type ProvisionProgress

type ProvisionProgress struct {
	JobID      string `json:"job_id"`
	ServerID   string `json:"server_id"`
	Step       int    `json:"step"`
	TotalSteps int    `json:"total_steps"`
	StepName   string `json:"step_name"`
	Status     string `json:"status"` // "running", "completed", "failed"
	Message    string `json:"message,omitempty"`
	Error      string `json:"error,omitempty"`
}

ProvisionProgress is sent during provisioning to report step status.

type ProvisionRequest

type ProvisionRequest struct {
	ServerID        string            `json:"server_id"`
	NodeName        string            `json:"node_name"`
	Network         string            `json:"network"` // "mainnet" or "testnet"
	ImageTag        string            `json:"image_tag"`
	Port            int               `json:"port"`
	RedundancyLevel int               `json:"redundancy_level"` // 0 = main/active, 1 = fallback
	SyncMode        string            `json:"sync_mode"`        // "fast" (default), "full-db", "genesis"
	GenerateKeys    bool              `json:"generate_keys"`
	ConfigOverrides map[string]string `json:"config_overrides,omitempty"`
}

ProvisionRequest is the request body for provisioning a new Klever node.

type RegistrationRequest

type RegistrationRequest struct {
	Token    string `json:"token"`
	Hostname string `json:"hostname"`
	OS       string `json:"os"`
	IP       string `json:"ip"`
}

RegistrationRequest is sent by the agent during initial registration.

type RegistrationResponse

type RegistrationResponse struct {
	ServerID  string `json:"server_id"`
	CertPEM   string `json:"cert_pem"`
	KeyPEM    string `json:"key_pem"`
	CACertPEM string `json:"ca_cert_pem"`
}

RegistrationResponse is sent by the dashboard after successful registration.

type ResetDBRequest added in v0.3.85

type ResetDBRequest struct {
	NodeID        string `json:"node_id"`
	ContainerName string `json:"container_name"`
	DataDir       string `json:"data_dir"`
}

ResetDBRequest is the request body for a fast-reset: delete a node's local chain DB and restart it with --start-in-epoch so it re-bootstraps from the latest epoch. This is deliberately NOT a full-history restore — it is for operators who do not need archival history and want a quick fresh sync.

type RestoreDBRequest added in v0.3.78

type RestoreDBRequest struct {
	NodeID        string `json:"node_id"`
	ContainerName string `json:"container_name"`
	DataDir       string `json:"data_dir"`
	Network       string `json:"network"` // "mainnet" or "testnet"
}

RestoreDBRequest is the request body for restoring a node's chain DB from the official Klever FullNode backup snapshot.

type Server

type Server struct {
	ID            string         `json:"id"`
	Name          string         `json:"name"`
	DisplayName   string         `json:"display_name,omitempty"`
	Hostname      string         `json:"hostname"`
	IPAddress     string         `json:"ip_address"`
	PublicIP      string         `json:"public_ip,omitempty"`
	Region        string         `json:"region,omitempty"`
	OSInfo        string         `json:"os_info,omitempty"`
	AgentVersion  string         `json:"agent_version,omitempty"`
	Status        string         `json:"status"` // "online", "offline", "updating"
	LastHeartbeat int64          `json:"last_heartbeat"`
	Certificate   []byte         `json:"certificate,omitempty"` // Encrypted at rest
	RegisteredAt  int64          `json:"registered_at"`
	UpdatedAt     int64          `json:"updated_at"`
	Metadata      map[string]any `json:"metadata,omitempty"`
}

Server represents a registered agent/server.

type SystemMetrics

type SystemMetrics struct {
	CPUPercent  float64 `json:"cpu_percent"`
	MemTotal    uint64  `json:"mem_total"`
	MemUsed     uint64  `json:"mem_used"`
	MemPercent  float64 `json:"mem_percent"`
	DiskTotal   uint64  `json:"disk_total"`
	DiskUsed    uint64  `json:"disk_used"`
	DiskPercent float64 `json:"disk_percent"`
	LoadAvg1    float64 `json:"load_avg_1"`
	LoadAvg5    float64 `json:"load_avg_5"`
	LoadAvg15   float64 `json:"load_avg_15"`
	CollectedAt int64   `json:"collected_at"`
}

SystemMetrics holds system-level resource usage data collected by the agent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL