From: Chris Duncan Date: Wed, 20 Aug 2025 20:50:42 +0000 (-0700) Subject: Avoid calling account rep endpoint many times if account has no frontier anyway. X-Git-Tag: v0.10.5~41^2~29 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=68db0820e113ce6e622b0c35b545690334295870;p=libnemo.git Avoid calling account rep endpoint many times if account has no frontier anyway. --- diff --git a/src/lib/wallet/refresh.ts b/src/lib/wallet/refresh.ts index bd6372d..8347907 100644 --- a/src/lib/wallet/refresh.ts +++ b/src/lib/wallet/refresh.ts @@ -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)