Skip to content

Commit

Permalink
fix(backend): call circulating supply only once (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherrybarry authored Nov 11, 2024
1 parent 774e068 commit b6ad69f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/backend/src/services/dailyStatsNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import config from '#config';
import cg from '#libs/cg';
import dayjs from '#libs/dayjs';
import knex from '#libs/knex';
import { circulatingSupply } from '#libs/supply';

type RawResp = {
rows: CountResp[];
Expand Down Expand Up @@ -69,7 +68,11 @@ const blockData = async (day: Dayjs) => {
let supply: null | string = null;

if (config.network === Network.MAINNET && lastBlock) {
supply = await circulatingSupply(lastBlock, config.rpcUrl);
const stats = await knex('stats').first();

if (stats) {
supply = stats?.circulating_supply;
}
}

return {
Expand Down

0 comments on commit b6ad69f

Please sign in to comment.