Skip to content

Commit

Permalink
fix cache mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzshia committed Jun 21, 2024
1 parent 84b6ab0 commit b6bb8d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cache/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { BasicPoolInfo } from '@raydium-io/raydium-sdk-v2'
import { PublicKey } from '@solana/web3.js'
import jsonfile from 'jsonfile'
import fs from 'fs'
import path from 'path'

const filePath = './src/data/pool_data.json'
const filePath = path.join(__dirname, '../data/pool_data.json')

export const readCachePoolData = (cacheTime?: number) => {
let cacheData: { time: number; ammPools: BasicPoolInfo[]; clmmPools: BasicPoolInfo[]; cpmmPools: BasicPoolInfo[] } = {
Expand Down Expand Up @@ -60,6 +62,11 @@ export const writeCachePoolData = (data: {
cpmmPools: BasicPoolInfo[]
}) => {
console.log('caching all pool basic info..')
fs.mkdir(path.join(__dirname, '../data'), (err) => {
if (err) {
return console.error(err)
}
})
jsonfile
.writeFile(filePath, {
time: Date.now(),
Expand Down

0 comments on commit b6bb8d4

Please sign in to comment.