Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chef-ryan committed Feb 14, 2025
1 parent b25b4a5 commit 835d5fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/views/GaugesVoting/hooks/useUserVote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import dayjs from 'dayjs'
import useAccountActiveChain from 'hooks/useAccountActiveChain'
import { useGaugesVotingContract } from 'hooks/useContract'
import { useEffect, useMemo } from 'react'
import { publicClient as getPublicClient } from 'utils/viem'
import { isAddressEqual } from 'utils'
import { publicClient as getPublicClient } from 'utils/viem'
import { Address, Hex, zeroAddress } from 'viem'
import { useCurrentBlockTimestamp } from 'views/CakeStaking/hooks/useCurrentBlockTimestamp'
import { useVeCakeUserInfo } from 'views/CakeStaking/hooks/useVeCakeUserInfo'
Expand Down Expand Up @@ -197,7 +197,7 @@ export const useUserVote = (gauge: Gauge | undefined, submitted?: boolean, usePr
})
: []
const [[nativeSlope, nativePower, nativeEnd], lastVoteTime] = response
const voteLocked = dayjs.unix(Number(lastVoteTime)).add(10, 'day').isAfter(dayjs.unix(currentTimestamp))
const voteLocked = Boolean(lastVoteTime)

return {
hash: gauge?.hash as Hex,
Expand Down
9 changes: 7 additions & 2 deletions packages/gauges/src/cacheByLRU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ export const cacheByLRU = <T extends AsyncFunction<any>>(fn: T, { ttl, key }: Ca
const cacheKey = calcCacheKey(key(args), epochId)
// logger(cacheKey, `exists=${cache.has(cacheKey)}`)
if (cache.has(cacheKey)) {
// logger('cache hit', cacheKey)
return cache.get(cacheKey)
}

const promise = fn(...args)

cache.set(cacheKey, promise)
// logger(`cache set`, cacheKey)

if (epochId > 0) {
const prevKey = calcCacheKey(key(args), epochId - 1)
if (cache.has(prevKey)) {
return cache.get(prevKey)
}
}

try {
return await promise
Expand Down

0 comments on commit 835d5fd

Please sign in to comment.