Skip to content

Cache coin symbol counts and refactor duplicate-symbol detection in pool.js - #14

Merged
MoneroOcean merged 1 commit into
masterfrom
codex/determine-maximum-coin-object-size
May 27, 2026
Merged

Cache coin symbol counts and refactor duplicate-symbol detection in pool.js#14
MoneroOcean merged 1 commit into
masterfrom
codex/determine-maximum-coin-object-size

Conversation

@MoneroOcean

Copy link
Copy Markdown
Owner

Motivation

  • Improve performance when resolving duplicate coin symbols by avoiding repeated scans of poolStats.coins for each lookup.
  • Ensure stable duplicate detection when poolStats.coins reference hasn't changed by caching computed symbol counts.
  • Handle empty/invalid inputs early to avoid unnecessary work.

Description

  • Introduced a WeakMap named coinSymbolCountsCache to cache symbol count maps keyed by the poolStats object.
  • Refactored hasDuplicateCoinSymbol to early-return when the slug is empty and to consult cached counts via a new getCoinSymbolCounts function.
  • Implemented getCoinSymbolCounts to compute a Map of slug -> count from coinStatsRows(poolStats), cache it with the coins reference as coinsRef, and return the counts.
  • Updated counting logic to skip empty slugs and to use the cached counts for duplicate checks (counts.get(wanted) > 1).

Testing

  • Ran the test suite with npm test, which passed successfully.
  • Exercised coin routing and duplicate detection logic through unit tests covering coinRouteId, coinRouteSlug, and hasDuplicateCoinSymbol, all of which passed.

Codex Task

@MoneroOcean
MoneroOcean merged commit 746d566 into master May 27, 2026
2 checks passed
@MoneroOcean
MoneroOcean deleted the codex/determine-maximum-coin-object-size branch May 27, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant