Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
reverse bucket loop order, to exit when an index when interval alread…
Browse files Browse the repository at this point in the history
…y exist (#799)
  • Loading branch information
fuxingloh authored Feb 21, 2022
1 parent d8e3caf commit 1712760
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/module.indexer/model/dftx/pool.swap.aggregated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export class PoolSwapAggregatedIndexer extends DfTxIndexer<PoolSwap> {
async indexBlockStart (block: RawBlock): Promise<void> {
const poolPairs = await this.poolPairTokenMapper.listAllDesc()

for (const poolPair of poolPairs) {
for (const interval of AggregatedIntervals) {
for (const interval of AggregatedIntervals) {
for (const poolPair of poolPairs) {
const previous = await this.aggregatedMapper.query(`${poolPair.poolPairId}-${interval as number}`, 1)
const bucket = getBucket(block, interval)

if (previous.length === 1 && previous[0].bucket >= bucket) {
// Going from a desc-ing order, we can just check if the most recent PoolSwap Aggregation Bucket is added.
continue
break
}

await this.createNewBucket(block, poolPair.poolPairId, interval)
Expand Down

0 comments on commit 1712760

Please sign in to comment.