valsigner

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownSignBytes = errors.New("valsigner: unknown sign bytes")
	ErrRuleDropped      = errors.New("valsigner: signature dropped by control rule")
)

Functions

This section is empty.

Types

type Action

type Action string
const (
	ActionDrop  Action = "drop"
	ActionDelay Action = "delay"
)

type ControllableSigner

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

func NewControllableSigner

func NewControllableSigner(signer types.Signer, controller *Controller, logger *slog.Logger) *ControllableSigner

func (*ControllableSigner) Close

func (c *ControllableSigner) Close() error

func (*ControllableSigner) PubKey

func (c *ControllableSigner) PubKey() crypto.PubKey

func (*ControllableSigner) Sign

func (c *ControllableSigner) Sign(signBytes []byte) ([]byte, error)

type Controller

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

func NewController

func NewController() *Controller

func (*Controller) ClearRule

func (c *Controller) ClearRule(phase Phase)

func (*Controller) Evaluate

func (c *Controller) Evaluate(target SignedTarget) (Rule, bool)

func (*Controller) Reset

func (c *Controller) Reset()

func (*Controller) SetRule

func (c *Controller) SetRule(phase Phase, rule Rule)

func (*Controller) Snapshot

func (c *Controller) Snapshot() (map[Phase]*RuleView, map[Phase]PhaseStats)

type Phase

type Phase string
const (
	PhaseProposal  Phase = "proposal"
	PhasePrevote   Phase = "prevote"
	PhasePrecommit Phase = "precommit"
)

func ParsePhase

func ParsePhase(raw string) (Phase, error)

type PhaseStats

type PhaseStats struct {
	Matched   int64      `json:"matched"`
	Dropped   int64      `json:"dropped"`
	Delayed   int64      `json:"delayed"`
	LastMatch *TargetHit `json:"last_match,omitempty"`
}

type Rule

type Rule struct {
	Action Action        `json:"action"`
	Height *int64        `json:"height,omitempty"`
	Round  *int          `json:"round,omitempty"`
	Delay  time.Duration `json:"-"`
}

func ParseRuleRequest

func ParseRuleRequest(raw ruleRequest) (Rule, error)

func (Rule) Matches

func (r Rule) Matches(target SignedTarget) bool

func (Rule) View

func (r Rule) View() *RuleView

type RuleView

type RuleView struct {
	Action Action `json:"action"`
	Height *int64 `json:"height,omitempty"`
	Round  *int   `json:"round,omitempty"`
	Delay  string `json:"delay,omitempty"`
}

type Server

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

func NewServer

func NewServer(keyFile, controlAddr, remoteAddr string, logger *slog.Logger) (*Server, error)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

type SignedTarget

type SignedTarget struct {
	Phase  Phase
	Height int64
	Round  int
}

func ClassifySignBytes

func ClassifySignBytes(signBytes []byte) (SignedTarget, error)

type StateView

type StateView struct {
	Address crypto.Address       `json:"address"`
	PubKey  string               `json:"pub_key"`
	Rules   map[Phase]*RuleView  `json:"rules"`
	Stats   map[Phase]PhaseStats `json:"stats"`
}

type TargetHit

type TargetHit struct {
	Height int64     `json:"height"`
	Round  int       `json:"round"`
	At     time.Time `json:"at"`
}

Jump to

Keyboard shortcuts

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