status

package
v1.22.9 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoNetwork indicates no nodes are running for a network status check.
	ErrNoNetwork = errors.New("no network running")
)

Functions

func FormatCChainBalanceLUX

func FormatCChainBalanceLUX(weiHex string) string

FormatCChainBalanceLUX converts C-chain balance (wei hex) to human-readable LUX

func FormatNLUXToLUX

func FormatNLUXToLUX(nLUX uint64) string

FormatNLUXToLUX converts nLUX (nanoLUX) to human-readable LUX

Types

type ActiveAccount

type ActiveAccount struct {
	Index         int    `json:"index"`
	PChainAddress string `json:"pChainAddress"`
	XChainAddress string `json:"xChainAddress"`
	CChainAddress string `json:"cChainAddress"`
}

ActiveAccount represents the currently active account for network operations

type ChainStatus

type ChainStatus struct {
	Alias         string // "c", "p", "x", "dex", etc.
	Kind          string // "evm", "pchain", "xchain", "custom"
	Height        uint64
	BlockTime     *time.Time
	RPC_OK        bool
	LatencyMS     int
	ChainID       string
	Syncing       interface{} // bool or sync progress object
	Metadata      map[string]interface{}
	LastError     string
	PluginVersion string // For custom chains
	PluginName    string // For custom chains
	BlockchainID  string // For custom chains
	VMID          string // For custom chains
}

ChainStatus represents the status of a chain

type EVMHeightResolver

type EVMHeightResolver struct{}

EVMHeightResolver resolves heights for EVM-compatible chains

func (*EVMHeightResolver) Height

func (r *EVMHeightResolver) Height(ctx context.Context, url string) (uint64, map[string]any, error)

func (*EVMHeightResolver) Kind

func (r *EVMHeightResolver) Kind() string

type EVMStatus

type EVMStatus struct {
	Name            string
	Network         string
	ChainID         uint64
	Height          uint64
	LatestTime      *time.Time
	Syncing         interface{} // bool or sync progress object
	ClientVersion   string
	PluginVersion   string
	Endpoints       []EndpointStatus
	DriftDetected   bool
	ChainIDMismatch bool
}

EVMStatus represents the status of a tracked EVM

type EndpointStatus

type EndpointStatus struct {
	ChainAlias string
	URL        string
	OK         bool
	LatencyMS  int
	LastError  string
}

EndpointStatus represents the status of an RPC endpoint

type FallbackHeightResolver

type FallbackHeightResolver struct{}

FallbackHeightResolver tries EVM first, then falls back to unknown

func (*FallbackHeightResolver) Height

func (r *FallbackHeightResolver) Height(ctx context.Context, url string) (uint64, map[string]any, error)

func (*FallbackHeightResolver) Kind

func (r *FallbackHeightResolver) Kind() string

type HeightResolver

type HeightResolver interface {
	Height(ctx context.Context, url string) (height uint64, meta map[string]any, err error)
	Kind() string // "evm", "pchain", "xchain", "custom", etc.
}

HeightResolver defines the interface for resolving chain heights

func GetResolverForChain

func GetResolverForChain(chainAlias string) HeightResolver

GetResolverForChain returns the appropriate resolver for a chain alias

type Network

type Network struct {
	Name          string
	Nodes         []Node
	Chains        []ChainStatus
	Endpoints     []EndpointStatus
	Metadata      NetworkMetadata
	Validators    []ValidatorAccount // Validator accounts with addresses and balances
	ActiveAccount *ActiveAccount     // Currently active account for operations
}

Network represents a Lux network (mainnet, testnet, devnet, custom)

type NetworkMetadata

type NetworkMetadata struct {
	GRPCPort   int
	NodesCount int
	VMsCount   int
	Controller string // "on" or "off"
	Status     string // "up", "down", "stopped", "error"
	LastError  string // Error message if Status is "error"
}

NetworkMetadata contains additional network information

type Node

type Node struct {
	ID               string
	HTTPURL          string
	NodeID           string
	Version          string
	CoreVersion      string
	EVMVersion       string
	NetrunnerVersion string
	PeerCount        int
	Uptime           string
	OK               bool
	LatencyMS        int
	LastError        string
	GPUAccelerated   bool
	GPUDriverVersion string
	GPUDevice        string
	PChainAddress    string
	XChainAddress    string
	CChainAddress    string
	// Balances (in nLUX for P/X, wei for C)
	PChainBalance uint64
	XChainBalance uint64
	CChainBalance string // hex string for large balances
}

Node represents a network node

type PChainHeightResolver

type PChainHeightResolver struct{}

PChainHeightResolver resolves heights for P-Chain

func (*PChainHeightResolver) Height

func (r *PChainHeightResolver) Height(ctx context.Context, url string) (uint64, map[string]any, error)

func (*PChainHeightResolver) Kind

func (r *PChainHeightResolver) Kind() string

type ProbeResult

type ProbeResult struct {
	OK        bool
	LatencyMS int
	Height    uint64
	Meta      map[string]interface{}
	Error     error
}

ProbeResult contains the result of a single probe

type ProgressTracker

type ProgressTracker struct {
	// contains filtered or unexported fields
}

ProgressTracker handles progress reporting and UX

func NewProgressTracker

func NewProgressTracker(writer io.Writer) *ProgressTracker

NewProgressTracker creates a new progress tracker

func (*ProgressTracker) CompleteStep

func (pt *ProgressTracker) CompleteStep(stepName string)

CompleteStep marks a step as completed

func (*ProgressTracker) CreateProgressBar

func (pt *ProgressTracker) CreateProgressBar(task string, total int) *progressbar.ProgressBar

CreateProgressBar creates a progress bar for a specific task

func (*ProgressTracker) FailStep

func (pt *ProgressTracker) FailStep(stepName string, err error)

FailStep marks a step as failed

func (*ProgressTracker) PrintError

func (pt *ProgressTracker) PrintError(message string)

PrintError prints an error message

func (*ProgressTracker) PrintInfo

func (pt *ProgressTracker) PrintInfo(message string)

PrintInfo prints an informational message

func (*ProgressTracker) PrintSuccess

func (pt *ProgressTracker) PrintSuccess(message string)

PrintSuccess prints a success message

func (*ProgressTracker) PrintWarning

func (pt *ProgressTracker) PrintWarning(message string)

PrintWarning prints a warning message

func (*ProgressTracker) StartStep

func (pt *ProgressTracker) StartStep(stepName string)

StartStep begins a new step with optional message

func (*ProgressTracker) Summary

func (pt *ProgressTracker) Summary(duration time.Duration, networks int, nodes int, chains int)

Summary prints a summary of the operation

func (*ProgressTracker) UpdateStep

func (pt *ProgressTracker) UpdateStep(message string)

UpdateStep updates the current step progress

type StatusFormatter

type StatusFormatter struct {
	// contains filtered or unexported fields
}

StatusFormatter handles formatting of status output

func NewStatusFormatter

func NewStatusFormatter(writer io.Writer) *StatusFormatter

NewStatusFormatter creates a new formatter

func (*StatusFormatter) FormatChainStatus

func (f *StatusFormatter) FormatChainStatus(result *StatusResult)

FormatChainStatus provides a compact chain status format

func (*StatusFormatter) FormatJSON

func (f *StatusFormatter) FormatJSON(result *StatusResult) error

FormatJSON outputs the status as JSON

func (*StatusFormatter) FormatNetworkStatus

func (f *StatusFormatter) FormatNetworkStatus(result *StatusResult)

FormatNetworkStatus formats network status in the requested clean format

func (*StatusFormatter) FormatNodeStatus

func (f *StatusFormatter) FormatNodeStatus(result *StatusResult)

FormatNodeStatus provides a compact node status format

func (*StatusFormatter) FormatStatusSummary

func (f *StatusFormatter) FormatStatusSummary(result *StatusResult)

FormatStatusSummary provides a compact summary format

func (*StatusFormatter) FormatYAML

func (f *StatusFormatter) FormatYAML(result *StatusResult) error

FormatYAML outputs the status as YAML

type StatusResult

type StatusResult struct {
	Networks    []Network
	TrackedEVMs []EVMStatus
	Timestamp   time.Time
	DurationMS  int
}

StatusResult contains the complete status information

type StatusService

type StatusService struct {
	// contains filtered or unexported fields
}

StatusService handles status probing and reporting

func NewStatusService

func NewStatusService() *StatusService

NewStatusService creates a new status service

func NewStatusServiceWithProgress

func NewStatusServiceWithProgress(progress interface{}) *StatusService

NewStatusServiceWithProgress creates a new status service with a progress bar (if needed)

func (*StatusService) GetStatus

func (s *StatusService) GetStatus(ctx context.Context) (*StatusResult, error)

GetStatus retrieves the status of all networks and chains

func (*StatusService) QueryCChainBalance

func (s *StatusService) QueryCChainBalance(ctx context.Context, baseURL, address string) (string, error)

QueryCChainBalance queries the C-chain balance for an address (0x format)

func (*StatusService) QueryPChainBalance

func (s *StatusService) QueryPChainBalance(ctx context.Context, baseURL, address string) (uint64, error)

QueryPChainBalance queries the P-chain balance for an address

func (*StatusService) QueryXChainBalance

func (s *StatusService) QueryXChainBalance(ctx context.Context, baseURL, address string) (uint64, error)

QueryXChainBalance queries the X-chain balance for an address

type TrackedEVM

type TrackedEVM struct {
	Name         string // zoo, hanzo, spc
	Network      string // mainnet, testnet
	RPCs         []string
	BlockchainID string // if available
	VMID         string // if available
}

TrackedEVM represents a tracked EVM chain (Zoo, Hanzo, SPC, etc.)

type ValidatorAccount

type ValidatorAccount struct {
	Index         int    `json:"index"`
	NodeID        string `json:"nodeID"`
	PChainAddress string `json:"pChainAddress"`
	XChainAddress string `json:"xChainAddress"`
	CChainAddress string `json:"cChainAddress"` // 0x format
	// Balances
	PChainBalance    uint64 `json:"pChainBalance"`    // nLUX
	XChainBalance    uint64 `json:"xChainBalance"`    // nLUX
	CChainBalance    string `json:"cChainBalance"`    // wei (hex)
	CChainBalanceLUX string `json:"cChainBalanceLUX"` // human readable
	// Staking info
	StakeWeight  uint64 `json:"stakeWeight"`
	DelegatorFee uint64 `json:"delegatorFee"`
	IsActive     bool   `json:"isActive"` // Is this the active account for operations
}

ValidatorAccount represents a validator's addresses and balances

type XChainHeightResolver

type XChainHeightResolver struct{}

XChainHeightResolver resolves heights for X-Chain

func (*XChainHeightResolver) Height

func (r *XChainHeightResolver) Height(ctx context.Context, url string) (uint64, map[string]any, error)

func (*XChainHeightResolver) Kind

func (r *XChainHeightResolver) Kind() string

Jump to

Keyboard shortcuts

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