Documentation
¶
Overview ¶
Package alt persists Address Lookup Table contents to prefetch.db -- see cmd/alt.go, the only writer.
Index ¶
- Variables
- func ExportJSON(db *sql.DB, path string) error
- func RecordUsage(db *sql.DB, entries []AccountUsageEntry) error
- func Replace(db *sql.DB, tablePubkey sgo.PublicKey, accounts []sgo.PublicKey) error
- func TopUsedAccounts(db *sql.DB, n int) ([]sgo.PublicKey, error)
- type AccountUsageEntry
- type LookupTableEntry
Constants ¶
This section is empty.
Variables ¶
var Schema string
Functions ¶
func ExportJSON ¶
ExportJSON writes every address_lookup_table row to path as a JSON array of LookupTableEntry, ordered by (table_pubkey, position) -- that order is load-bearing (see schema.sql's own doc comment: it's the real on-chain lookup index), and build.rs's grouping-by-adjacency reconstruction depends on rows arriving pre-sorted this way, so this export preserves the exact ORDER BY the old direct query used.
func RecordUsage ¶
func RecordUsage(db *sql.DB, entries []AccountUsageEntry) error
RecordUsage persists entries into account_usage. Each entry's Count is the reporting bot's own cumulative-since-process-start tally as of this report, not a delta -- so this upserts (overwrites), it does not sum across reports, which would double-count every account on every subsequent report from the same long-running bot.
func Replace ¶
Replace persists accounts as tablePubkey's complete, authoritative address list, in order -- position i is on-chain lookup index i (see schema.sql). Any previous row set for tablePubkey is deleted first, so a re-run against a table that has since shrunk doesn't leave stale rows at higher positions. Rows for other lookup tables are untouched, so multiple tables accumulate across runs.
func TopUsedAccounts ¶
TopUsedAccounts returns up to n accounts from account_usage, ranked by reported usage count descending (pubkey ascending as a deterministic tiebreak) -- the replacement ranking source for cmd/alt.go, in place of scanning transaction history via RPC.
Types ¶
type AccountUsageEntry ¶
AccountUsageEntry is one (account, usage count) pair from a bot's MessageSend::CommonAddressUpdate report.
func ParseAccountUsage ¶
func ParseAccountUsage(value []byte) ([]AccountUsageEntry, error)
ParseAccountUsage decodes a KeyFlagCommonAccountUsage message value: [n_entries u16 LE][(pubkey 32B, count u32 LE) x n_entries], exactly what MessageOutbound::write's MessageSend::CommonAddressUpdate arm (src/message.rs) serializes.
type LookupTableEntry ¶
type LookupTableEntry struct {
TablePubkey sgo.PublicKey `json:"table_pubkey"`
Position int `json:"position"`
AccountPubkey sgo.PublicKey `json:"account_pubkey"`
}
LookupTableEntry is one address_lookup_table row, JSON-shaped for catscope-rust-bot's build.rs to read instead of opening prefetch.db directly. No full-table Go reader exists yet (Replace only writes, TopUsedAccounts reads the separate account_usage table) -- this is a fresh, minimal type for exactly this export.
Source Files
¶
- export.go
- schema.go
- store.go