chainstate

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package chainstate is the one concrete api.ChainState -- every cmd command that only needs a prefetch.db handle (no live state.Client subscription) previously called store.Open directly and duplicated its own defer-close boilerplate; this collects that into one constructor.

Real limitation, not papered over: Account (the live-account half of api.ChainState) is a strict subset of what most cmd commands actually need from a state.Client. It answers "what is this one account right now" (via util.FetchAccount's single depth-1 subscribe-then-cancel), not a live subscription (state.Client.Hook, used directly by cmd/watchobligations.go) or an aggregated multi-account read (util.FetchWalletBalance, used by cmd/watchpnl.go). Commands built around a raw state.Client passed into an external constructor (prefetch.Create, the per-DEX prefetch.*.Create functions) need that literal type, which api.ChainState does not expose -- those commands are deliberately left alone rather than forced through an interface that doesn't fit their real access pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(parentCtx context.Context, dbPath string, stateClient state.Client) (api.ChainState, error)

Create opens dbPath (via store.Open, applying its schema the same way every direct store.Open caller already relied on) and returns it as an api.ChainState. stateClient is optional -- pass the zero value (state.Client{}) for a command that only ever calls Database(), the same commands that never declared a stateClient variable at all before this. Closing the returned value closes the underlying db; callers must not also separately defer db.Close().

Types

This section is empty.

Source Files

  • chainstate.go

Jump to

Keyboard shortcuts

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