Skip to content

Commit

Permalink
define lock outside try block
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jun 20, 2024
1 parent 8807104 commit e2be067
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/routes/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,17 +426,15 @@ router.post(

// its a new v2 user, lets set his nonce
if (!nonce) {
let lock;
const lockKey = `metadata-lock-${key}`;
const lock = await redlock.acquire([lockKey], 5000);
let startTime = 0n;
let gettingNonceTime = 0n;
let gettingPubNonceTime = 0n;
let insertingTime = 0n;
let redisSetTime = 0n;
const lockKey = `metadata-lock-${key}`;

try {
lock = await redlock.acquire([lockKey], 5000);

startTime = process.hrtime.bigint();
// check if someone else has set it
nonce = await getNonce(true);
Expand Down

0 comments on commit e2be067

Please sign in to comment.