nodesettings

package
v0.70.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package nodesettings holds the policy for settings that are persisted on first start and enforced on every subsequent start. It has no database or configuration dependencies so the policy can be tested in isolation.

Index

Constants

View Source
const (
	LatchOff = "off"
	LatchOn  = "on"
)

Latch and taint value encodings.

View Source
const NoStartEra = "none"

NoStartEra is the canonical persisted value recording that a database was created (or last confirmed) with no start era override. start_era's class is FrozenFillOnce, which treats an empty configured value as "not known yet" (see evaluate.go) -- correct for a caller that genuinely cannot supply the gate, but wrong for the ordinary case of a full node startup with no --start-era flag, where "" meant "nothing to compare" and the gate was silently never recorded. Every writer that can distinguish "no start era" from "don't know" must persist this sentinel instead of "", so a later --start-era dijkstra against that database is compared against something rather than filling in for free.

Variables

This section is empty.

Functions

func EncodeLatchBool

func EncodeLatchBool(enabled bool, carried string) string

EncodeLatchBool renders a LatchBool value. carried is the associated setting, such as a pledge leverage factor, and is empty for gates that carry nothing.

Types

type Class

type Class int

Class determines how a gate reacts when the configured value differs from the persisted one.

const (
	// Frozen requires the configured value to equal the persisted one.
	Frozen Class = iota
	// FrozenFillOnce behaves like Frozen but treats an empty configured
	// value as "not known yet" and an empty persisted value as fillable.
	FrozenFillOnce
	// LatchEnum permits movement forward through Ordered only.
	LatchEnum
	// LatchBool permits off to on only. Values are LatchOff, LatchOn, or
	// LatchOn plus a carried value (see EncodeLatchBool).
	LatchBool
	// Taint is a sticky bit: once on it stays on and stops being compared,
	// and it may never be turned on for a database that lacks it.
	Taint
)

type Gate

type Gate struct {
	// Name is the key stored in node_settings_gate.
	Name string
	// Label is the operator-facing name used in error messages. It defaults
	// to Name when empty. storage_mode and network must label themselves
	// "storage mode" and "network" to preserve the message wording that
	// existing tests in database/storage_mode_test.go assert against.
	Label string
	// Class selects the enforcement rule.
	Class Class
	// Ordered lists permitted LatchEnum values in transition order. It is
	// unused by every other class.
	Ordered []string
	// OverrideEligible allows a persisted value to supply the effective
	// value when the configured one was not set explicitly. A gate is
	// eligible only when its persisted value is self-sufficient, needing
	// no companion configuration that is not itself persisted.
	OverrideEligible bool
	// Remedy overrides the operator-facing fix description used in a
	// Mismatch's Reason for the Frozen and FrozenFillOnce classes, whose
	// default reason ("changing it requires re-syncing from scratch") is
	// wrong for a gate whose real fix is not a resync. Empty uses the
	// default.
	Remedy string
}

Gate describes one persisted setting.

func Gates

func Gates() []Gate

Gates returns the registry. Adding an entry here plus its test cases is the entire cost of gating a new setting; no schema change is needed.

type Mismatch

type Mismatch struct {
	Gate       string
	Label      string
	Persisted  string
	Configured string
	Reason     string
}

Mismatch is one fatal disagreement between the database and the configuration.

func (Mismatch) String

func (m Mismatch) String() string

String renders the operator-facing message. It uses the gate's Label so the existing wording in database/storage_mode_test.go keeps matching.

type Result

type Result struct {
	// Effective is the value the caller should actually use for each gate
	// present in configured, after any override.
	Effective Values
	// Writes are the values to persist. Empty when nothing changed.
	Writes Values
	// Mismatches is non-empty when startup must fail.
	Mismatches []Mismatch
}

Result is the outcome of an evaluation.

func Evaluate

func Evaluate(
	persisted Values,
	configured Values,
	explicit map[string]bool,
) Result

Evaluate applies the registry to a persisted and configured value set.

explicit reports, per gate, whether the configured value came from an operator (a flag, an environment variable, or a config file) rather than a built-in default. It is the only thing separating "resume what this database already is" from "the operator asked for something incompatible", so callers that genuinely mean every value they pass, such as database.New, mark them all explicit and get strict validation with no override behavior.

A gate absent from configured is skipped: the caller does not know that value yet, which is normal for tool paths that never load a cardano config.

type Values

type Values map[string]string

Values maps a gate name to its encoded value.

Jump to

Keyboard shortcuts

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