chore: don't validate Nonce in query (#1341)
Some checks failed
Build Docker image / docker (push) Waiting to run
Build / build (22) (push) Has been cancelled
Build / build (20) (push) Has been cancelled
Build / build (18) (push) Has been cancelled

By asking MongoDB to simply find the account by the ID and then validating the nonce ourselves, we save roughly 1ms.

Reviewed-on: #1341
This commit is contained in:
Sainan 2025-03-27 03:33:27 -07:00
parent d9b944175a
commit a622393933

View File

@ -74,11 +74,8 @@ export const getAccountForRequest = async (req: Request): Promise<TAccountDocume
throw new Error("Request is missing nonce parameter");
}
const account = await Account.findOne({
_id: req.query.accountId,
Nonce: nonce
});
if (!account) {
const account = await Account.findById(req.query.accountId);
if (!account || account.Nonce != nonce) {
throw new Error("Invalid accountId-nonce pair");
}
if (account.Dropped && req.query.ct) {