nodeutils

package
v1.57.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StateSyncChunkMetricsExist added in v1.53.0

func StateSyncChunkMetricsExist(ctx context.Context, metricsURL string) (bool, error)

Types

type Client

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

Client provides methods to interact with the node-utils HTTP server.

func NewClient

func NewClient(host string) *Client

NewClient creates a new node-utils client for the given host. The host should be a hostname or IP address without scheme or port.

func (*Client) GetCPUStats added in v1.44.0

func (c *Client) GetCPUStats(ctx context.Context, since time.Duration) (float64, error)

GetCPUStats returns the CPU usage percentage. If since is greater than 0, it returns the average over that duration.

func (*Client) GetDataSize

func (c *Client) GetDataSize(ctx context.Context) (int64, error)

GetDataSize returns the current size of the node's data directory in bytes.

func (*Client) GetLatestHeight

func (c *Client) GetLatestHeight(ctx context.Context) (int64, error)

GetLatestHeight returns the latest block height from the blockchain node.

func (*Client) GetMemoryStats added in v1.44.0

func (c *Client) GetMemoryStats(ctx context.Context, since time.Duration) (uint64, error)

GetMemoryStats returns the memory usage in bytes. If since is greater than 0, it returns the average over that duration.

func (*Client) IsStateSyncing added in v1.53.0

func (c *Client) IsStateSyncing(ctx context.Context) (bool, error)

IsStateSyncing returns true if the node is currently performing state-sync.

func (*Client) ListSnapshots

func (c *Client) ListSnapshots(ctx context.Context) ([]int64, error)

ListSnapshots returns a list of available snapshot heights.

func (*Client) RequiresUpgrade

func (c *Client) RequiresUpgrade(ctx context.Context) (bool, error)

RequiresUpgrade checks if the node requires an upgrade. Returns true if an upgrade is required, false otherwise.

func (*Client) ShutdownNodeUtilsServer

func (c *Client) ShutdownNodeUtilsServer(ctx context.Context) error

ShutdownNodeUtilsServer sends a shutdown signal to the node-utils server.

type NodeUtils

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

func New

func New(nodeBinaryName string, opts ...Option) (*NodeUtils, error)

func (*NodeUtils) Start

func (s *NodeUtils) Start() error

func (*NodeUtils) Stop

func (s *NodeUtils) Stop(force bool) error

func (*NodeUtils) StopNode

func (s *NodeUtils) StopNode() error

type Option

type Option func(*Options)

func CreateFifo

func CreateFifo(create bool) Option

func WithBlockThreshold

func WithBlockThreshold(n time.Duration) Option

func WithDataPath

func WithDataPath(path string) Option

func WithHaltHeight added in v1.40.0

func WithHaltHeight(height int64) Option

func WithHost

func WithHost(s string) Option

func WithPort

func WithPort(v int) Option

func WithTmkmsProxy

func WithTmkmsProxy(enable bool) Option

func WithTraceStore

func WithTraceStore(path string) Option

func WithUpgradesConfig

func WithUpgradesConfig(path string) Option

type Options

type Options struct {
	Host           string
	Port           int
	DataPath       string
	BlockThreshold time.Duration
	UpgradesConfig string
	TraceStore     string
	CreateFifo     bool
	TmkmsProxy     bool
	HaltHeight     int64
}

type ProcessStats added in v1.44.0

type ProcessStats struct {
	CPUTimeSec float64 `json:"cpu_time_sec"`     // total CPU time in seconds
	MemoryRSS  uint64  `json:"memory_rss_bytes"` // resident memory usage
}

func GetProcessStats added in v1.44.0

func GetProcessStats(proc *process.Process) (*ProcessStats, error)

GetProcessStats extracts CPU + memory usage from a gopsutil Process

type Upgrade

type Upgrade struct {
	Height int64         `json:"height"`
	Status string        `json:"status"`
	Image  string        `json:"image"`
	Source UpgradeSource `json:"source"`
}

type UpgradeChecker

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

func NewUpgradeChecker

func NewUpgradeChecker(configFile string) (*UpgradeChecker, error)

func (*UpgradeChecker) GetUpgrade

func (u *UpgradeChecker) GetUpgrade(height int64) (*Upgrade, error)

func (*UpgradeChecker) ShouldUpgrade

func (u *UpgradeChecker) ShouldUpgrade(height int64) bool

func (*UpgradeChecker) WatchConfigFile

func (u *UpgradeChecker) WatchConfigFile() error

type UpgradeSource

type UpgradeSource string
const (
	UpgradeScheduled = "scheduled"

	ManualUpgrade  UpgradeSource = "manual"
	OnChainUpgrade UpgradeSource = "on-chain"
)

type UpgradesConfig

type UpgradesConfig struct {
	Upgrades []Upgrade `json:"upgrades"`
}

Jump to

Keyboard shortcuts

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