diff --git a/uplc/src/plc.rs b/uplc/src/plc.rs index fab4ace..d6311eb 100644 --- a/uplc/src/plc.rs +++ b/uplc/src/plc.rs @@ -83,6 +83,22 @@ pub async fn run_plc_sync(db: DB, stats: Arc>) -> Result<()> { let mut total = 0; loop { + // todo this won't hold up after the backfill as it'll be slower + // and we likely won't get full batches. + if total % 500_000 == 0 { + println!("refreshing stats at {} ops", total); + + tokio::task::spawn_blocking({ + let db = db.clone(); + let mut stats = stats.clone().write_owned().await; + // todo this does make the api unavailable while it's working + // as the rwlock doesn't allow any readers while a writer is open + move || async move { stats.refresh(&db) } + }) + .await? + .await?; + } + println!("seen {} this session with seq {}", total, after); let url = format!("https://plc.directory/export?count=1000&after={}", after);