Skip to content

Switch to parallel network requests #331

@ECWireless

Description

@ECWireless

Close this issue if all data is able to be moved to a subgraph


Location: pages/api/pending-stake/[address].tsx, pages/api/score/[address].tsx, pages/api/regions/index.ts

Problem: Multiple API calls are made sequentially when they could run in parallel.

Example Fix:

// Before (sequential - 5s total)
const currentRound = await readContract(...);
const pendingStake = await readContract(...);
const pendingFees = await readContract(...);

// After (parallel - 2s total)
const currentRound = await readContract(...);
const [pendingStake, pendingFees] = await Promise.all([
  readContract(...),
  readContract(...)
]);

We could also probably just make a single RPC ping with viem's readContracts method, which would make uncached page loads multiple times faster.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions