mintinfo

package
v0.4.16 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 mintinfo provides a small shared cache of SPL Mint decimals, populated opportunistically by every prefetcher that discovers a mint (Orca, Raydium AMM/CPMM/CLMM) so a mint referenced by many pools (USDC, wSOL) is only ever fetched once per run, not once per pool.

Index

Constants

View Source
const MintAccountSize = 82

MintAccountSize is the fixed on-chain byte size of an SPL Token Mint account (mint_authority Option<Pubkey>(36) + supply u64(8) + decimals u8(1) + is_initialized bool(1) + freeze_authority Option<Pubkey>(36)).

Variables

View Source
var Schema string

Functions

func DecodeDecimals

func DecodeDecimals(body []byte) (uint8, error)

DecodeDecimals parses an SPL Mint account body and returns its decimals field. body must be exactly MintAccountSize bytes.

func ExportJSON

func ExportJSON(db *sql.DB, path string) error

ExportJSON writes every mint_info row to path as a JSON array of MintDecimals -- the same table build.rs currently reads three separate times (a soft-degrade decimals lookup for the router graph, a hard- panic lookup for curated symbol mints, and a soft-skip lookup for the trade-universe filter); this is one full snapshot all three can build their own in-memory map from.

Types

type MintDecimals

type MintDecimals struct {
	Mint     sgo.PublicKey `json:"mint"`
	Decimals uint8         `json:"decimals"`
}

MintDecimals is one mint_info row, JSON-shaped for catscope-rust-bot's build.rs to read instead of opening prefetch.db directly. mint_info has no dedicated Go struct today (Tracker only tracks which mints are known, not their decimals, in memory) -- this is a fresh, minimal type for exactly this export.

type Tracker

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

Tracker deduplicates mint-decimals discovery across concurrently running prefetchers and persists results to the mint_info table.

func New

func New(db *sql.DB) (*Tracker, error)

New loads any already-known mints from db (so a resumed run doesn't re-fetch decimals for mints a previous run already discovered) and returns a ready-to-use Tracker.

func (*Tracker) Known

func (t *Tracker) Known(mint sgo.PublicKey) bool

Known reports whether mint's decimals are already saved.

func (*Tracker) MarkPending

func (t *Tracker) MarkPending(mint sgo.PublicKey) bool

MarkPending records that a decimals fetch for mint is about to be issued. It returns true only the first time it's called for a given mint (across every prefetcher sharing this Tracker), telling the caller to actually subscribe; it returns false if the mint is already known or another prefetcher already has a fetch in flight for it.

func (*Tracker) Save

func (t *Tracker) Save(mint sgo.PublicKey, decimals uint8) error

Save persists mint's decimals using the tracker's own database handle. Only safe to call when the caller does NOT already hold an open transaction on the same database -- store.DB opens with a single- connection pool, so requesting a second connection from a goroutine that already holds the only one (via an open *sql.Tx) would deadlock. Callers that run inside their own CommitStart/CommitFinish transaction (Raydium AMM/CPMM/CLMM) must use SaveTx instead.

func (*Tracker) SaveTx

func (t *Tracker) SaveTx(tx *sql.Tx, mint sgo.PublicKey, decimals uint8) error

SaveTx persists mint's decimals using the caller's own in-flight transaction, avoiding the single-connection deadlock described on Save.

Source Files

  • export.go
  • mintinfo.go
  • schema.go

Jump to

Keyboard shortcuts

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