]> git.codecow.com Git - libnemo.git/commitdiff
Avoid calling account rep endpoint many times if account has no frontier anyway.
authorChris Duncan <chris@zoso.dev>
Wed, 20 Aug 2025 20:50:42 +0000 (13:50 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 20 Aug 2025 20:50:42 +0000 (13:50 -0700)
src/lib/wallet/refresh.ts

index bd6372d904ec8e254fdfd146f7c58a0074773bb8..83479075f3d3ab998f4c2127159eaa65bbb39d0f 100644 (file)
@@ -36,8 +36,9 @@ export async function _refresh (wallet: Wallet, rpc: unknown, from: unknown, to:
                for (const account of accounts) {
                        account.balance = balances[account.address]?.balance
                        account.receivable = balances[account.address]?.receivable
-                       account.representative = representatives?.[account.address] ?? (await rpc.call('account_representative', { account: account.address }))?.representative
+                       account.representative = representatives?.[account.address]
                        if (frontiers[account.address] != null) {
+                               account.representative ??= (await rpc.call('account_representative', { account: account.address }))?.representative
                                account.frontier = frontiers[account.address]
                                const { subtype, contents: { balance, link, previous, representative, signature } } = blocks[account.frontier]
                                const frontierBlock = new Block(account, balance, previous, representative)