Skip to content

Commit

Permalink
chore: added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Aug 11, 2024
1 parent f440ab9 commit 2a3935e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getOrderbookActiveOrders({
return cachified({
cache: activeOrdersCache,
key: `orderbookActiveOrders-${orderbookAddress}-${userOsmoAddress}`,
ttl: 1500, // 1.5 seconds
ttl: 1500, // 6 seconds
getFreshValue: () =>
queryOrderbookActiveOrders({
orderbookAddress,
Expand Down
7 changes: 6 additions & 1 deletion packages/trpc/src/orderbook-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ export const orderbookRouter = createTRPCRouter({
return result;
};

const chunkedAddresses = chunk(contractAddresses, 8);
const chunkedAddresses = chunk(contractAddresses, 4);

const before = Date.now();
const ordersByContracts: MappedLimitOrder[] = [];
for (let i = 0; i < chunkedAddresses.length; i++) {
const beforeLoop = Date.now();
const contractOsmoAddresses = chunkedAddresses[i];
const orderPromises = contractOsmoAddresses.map(
async (contractOsmoAddress: string) => {
Expand Down Expand Up @@ -111,8 +113,11 @@ export const orderbookRouter = createTRPCRouter({
}
const newOrders = await Promise.all(orderPromises);
ordersByContracts.push(...newOrders.flat().flat());
console.log(`time-${i}`, Date.now() - beforeLoop);
}

console.log("time", Date.now() - before);

// const ordersByContracts = await Promise.all(promises);

return ordersByContracts.sort(defaultSortOrders);
Expand Down

0 comments on commit 2a3935e

Please sign in to comment.