simulator

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package simulator manages the lifecycle of vendor-provided wallet simulator binaries: downloading them to a local cache with SHA256 verification, starting them as a subprocess, and tearing them down.

This package is vendor-agnostic. Wallet-specific glue (which binaries to use, how to dial the running process) lives in bitbox/simulator, ledger/simulator, trezor/simulator, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitFor

func WaitFor(d time.Duration, cond func() error) error

WaitFor polls cond at 25ms intervals until it returns nil or d elapses. Used by vendor packages to wait for "simulator ready" (e.g. TCP port accepting connections).

Types

type Binary

type Binary struct {
	// Name is a human-readable label, used for cached filenames and logs
	// (e.g. "bitbox02-multi-v9.26.1-simulator1.0.0-linux-amd64").
	Name string
	// URL is the absolute download location.
	URL string
	// SHA256 is the lowercase hex-encoded expected digest.
	SHA256 string
}

Binary describes a downloadable simulator artifact.

type Cache

type Cache struct {
	Dir string
	// contains filtered or unexported fields
}

Cache is a content-addressed directory of downloaded simulator binaries. Repeated Resolve calls for the same Binary return immediately after the first download.

func NewCache

func NewCache(dir string) (*Cache, error)

NewCache returns a Cache backed by dir, creating the directory if needed.

func (*Cache) Resolve

func (c *Cache) Resolve(b Binary) (string, error)

Resolve returns the local path to b, downloading and verifying it if not already cached. The returned file has the executable bit set on POSIX.

type Process

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

Process is a running simulator subprocess.

func Start

func Start(binaryPath string) (*Process, error)

Start launches binaryPath as a subprocess. Stdout is captured and returned line-by-line via Stdout(); stderr is inherited from the parent.

The binary is wrapped with stdbuf -oL when available, so stdout is line-buffered for prompt readiness detection.

func (*Process) Stdout

func (p *Process) Stdout() io.Reader

Stdout returns the live stdout pipe.

func (*Process) Stop

func (p *Process) Stop() error

Stop terminates the subprocess. Idempotent.

Jump to

Keyboard shortcuts

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