Skip to content

feat: reuse paging-derived accounts to avoid redundant device I/O at unlock - #613

Draft
gantunesr wants to merge 5 commits into
mainfrom
gar/feat/ledger-page-cache
Draft

feat: reuse paging-derived accounts to avoid redundant device I/O at unlock#613
gantunesr wants to merge 5 commits into
mainfrom
gar/feat/ledger-page-cache

Conversation

@gantunesr

@gantunesr gantunesr commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary of the changes:

  • New private #pagingCache: Map<string, { hdPath, address, publicKey, chainCode? }> keyed by derivation path.
  • #getAccountsBIP44 now calls bridge.getPublicKey directly instead of this.unlock(path), so it can capture the full payload and stash { hdPath, address, publicKey: payload.publicKey, chainCode: payload.chainCode } into the cache. Error handling and the hdk update are preserved.
  • addAccounts checks #pagingCache.get(path) first; on a hit it reuses cached.address and skips unlock(path)bridge.getPublicKey. On a miss it falls back to await this.unlock(path). Note: The non-Ledger Live branch is unchanged.
  • Cache is invalidated on forgetDevice, setHdPath (when the path actually changes), destroy, and defensively at the start of addAccounts when the device is disconnected (!this.isConnected()).
  • New public invalidatePagingCache() method for external disconnect handlers, backed by private #invalidatePagingCache().

Examples

N/A

@gantunesr gantunesr changed the title feat: add paging cache for Ledger accounts feat: reuse paging-derived accounts to avoid redundant device I/O at unlock Jul 31, 2026
@gantunesr

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-api": "2.0.0-963e020",
  "@metamask-previews/hw-wallet-sdk": "1.0.0-963e020",
  "@metamask-previews/keyring-api": "24.0.0-963e020",
  "@metamask-previews/eth-hd-keyring": "15.0.0-963e020",
  "@metamask-previews/eth-ledger-bridge-keyring": "13.0.1-963e020",
  "@metamask-previews/eth-money-keyring": "4.0.0-963e020",
  "@metamask-previews/eth-qr-keyring": "3.0.0-963e020",
  "@metamask-previews/eth-simple-keyring": "13.0.0-963e020",
  "@metamask-previews/eth-trezor-keyring": "11.0.0-963e020",
  "@metamask-previews/keyring-internal-api": "12.0.0-963e020",
  "@metamask-previews/keyring-internal-snap-client": "11.0.0-963e020",
  "@metamask-previews/keyring-sdk": "3.0.0-963e020",
  "@metamask-previews/eth-snap-keyring": "24.0.0-963e020",
  "@metamask-previews/keyring-snap-client": "10.0.0-963e020",
  "@metamask-previews/keyring-snap-sdk": "10.0.0-963e020",
  "@metamask-previews/keyring-utils": "5.0.0-963e020"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant