chore: don't validate Nonce in query
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (18) (push) Successful in 42s
				
			
		
			
				
	
				Build / build (22) (push) Successful in 1m12s
				
			
		
			
				
	
				Build / build (20) (push) Successful in 1m13s
				
			
		
			
				
	
				Build / build (18) (pull_request) Successful in 43s
				
			
		
			
				
	
				Build / build (20) (pull_request) Successful in 1m12s
				
			
		
			
				
	
				Build / build (22) (pull_request) Successful in 1m13s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (18) (push) Successful in 42s
				
			Build / build (22) (push) Successful in 1m12s
				
			Build / build (20) (push) Successful in 1m13s
				
			Build / build (18) (pull_request) Successful in 43s
				
			Build / build (20) (pull_request) Successful in 1m12s
				
			Build / build (22) (pull_request) Successful in 1m13s
				
			By asking MongoDB to simply find the account by the ID and then validating the nonce ourselves, we save roughly 1ms.
This commit is contained in:
		
							parent
							
								
									5f9475f750
								
							
						
					
					
						commit
						02334f4a7e
					
				@ -74,11 +74,8 @@ export const getAccountForRequest = async (req: Request): Promise<TAccountDocume
 | 
				
			|||||||
        throw new Error("Request is missing nonce parameter");
 | 
					        throw new Error("Request is missing nonce parameter");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const account = await Account.findOne({
 | 
					    const account = await Account.findById(req.query.accountId);
 | 
				
			||||||
        _id: req.query.accountId,
 | 
					    if (!account || account.Nonce != nonce) {
 | 
				
			||||||
        Nonce: nonce
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    if (!account) {
 | 
					 | 
				
			||||||
        throw new Error("Invalid accountId-nonce pair");
 | 
					        throw new Error("Invalid accountId-nonce pair");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (account.Dropped && req.query.ct) {
 | 
					    if (account.Dropped && req.query.ct) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user