feature: slight rate limit in prover_sync fetch_leaf (#687)

buddies-main-deployment
James Prestwich 3 years ago committed by GitHub
parent e5328d3105
commit ff5fa65479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      rust/agents/processor/src/prover_sync.rs

@ -6,10 +6,13 @@ use optics_core::{
traits::{ChainCommunicationError, Common, Home}, traits::{ChainCommunicationError, Common, Home},
}; };
use rocksdb::DB; use rocksdb::DB;
use std::{ops::Range, sync::Arc}; use std::{ops::Range, sync::Arc, time::Duration};
use tokio::sync::{ use tokio::{
oneshot::{error::TryRecvError, Receiver}, sync::{
RwLock, oneshot::{error::TryRecvError, Receiver},
RwLock,
},
time::sleep,
}; };
use tracing::{debug, info, instrument}; use tracing::{debug, info, instrument};
@ -113,6 +116,9 @@ impl ProverSync {
Ok(leaf) Ok(leaf)
} else { } else {
debug!("Retrieving leaf from chain."); debug!("Retrieving leaf from chain.");
// slight rate limit
// TODO(James): make this not so kludgy
sleep(Duration::from_millis(100)).await;
match self.home.leaf_by_tree_index(leaf_index).await? { match self.home.leaf_by_tree_index(leaf_index).await? {
Some(leaf) => { Some(leaf) => {
debug!("Retrieved leaf from chain."); debug!("Retrieved leaf from chain.");

Loading…
Cancel
Save