From ce4d92e40e1c845ab771d5d252da29c2b0459359 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 25 Apr 2022 01:30:55 +0000 Subject: [PATCH] comment cleanup --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index dfdef905..20ae069a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -237,6 +237,7 @@ impl Web3ProxyState { } } Err(not_until) => { + // sleep (with a lock) until our rate limits should be available drop(read_lock); let write_lock = self.balanced_rpc_ratelimiter_lock.write().await; @@ -289,14 +290,13 @@ impl Web3ProxyState { } } + // we haven't returned an Ok, sleep and try again drop(read_lock); - let write_lock = self.balanced_rpc_ratelimiter_lock.write().await; - // TODO: some sort of lock here? - // we haven't returned an Ok, sleep and try again // unwrap should be safe since we would have returned if it wasn't set let deadline = earliest_not_until.unwrap().wait_time_from(self.clock.now()); + sleep(deadline).await; drop(write_lock);