From 0fa10a8e1c7aef2958809b4910887a9e0596d3e2 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Thu, 29 Dec 2022 07:51:10 +1300 Subject: [PATCH] Modify 'since' computation when pulling from relays on startup --- src/db/person_relay.rs | 1 + src/overlord/minion/mod.rs | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/db/person_relay.rs b/src/db/person_relay.rs index c69b757c..9846385a 100644 --- a/src/db/person_relay.rs +++ b/src/db/person_relay.rs @@ -102,6 +102,7 @@ impl DbPersonRelay { } /// Fetch oldest last_fetched among a set of public keys for a relay + #[allow(dead_code)] pub async fn fetch_oldest_last_fetched( pubkeys: &[PublicKeyHex], relay: &str, diff --git a/src/overlord/minion/mod.rs b/src/overlord/minion/mod.rs index 970f5e9a..bf1eaebe 100644 --- a/src/overlord/minion/mod.rs +++ b/src/overlord/minion/mod.rs @@ -3,7 +3,7 @@ mod handle_websocket; mod subscription; use crate::comms::BusMessage; -use crate::db::{DbPersonRelay, DbRelay}; +use crate::db::DbRelay; use crate::error::Error; use crate::globals::GLOBALS; use futures::{SinkExt, StreamExt}; @@ -265,16 +265,26 @@ impl Minion { // Compute how far to look back let (feed_since, special_since) = { - // Find the oldest 'last_fetched' among the 'person_relay' table. - // Null values will come through as 0. - let mut special_since: i64 = - DbPersonRelay::fetch_oldest_last_fetched(&pubkeys, self.url.inner()).await? as i64; - + // Get related settings let (overlap, feed_chunk) = { let settings = GLOBALS.settings.read().await.clone(); (settings.overlap, settings.feed_chunk) }; + /* + // Find the oldest 'last_fetched' among the 'person_relay' table. + // Null values will come through as 0. + let mut special_since: i64 = + DbPersonRelay::fetch_oldest_last_fetched(&pubkeys, &self.url.0).await? as i64; + */ + + // Start with where we left off, the time we last got something from + // this relay. + let mut special_since: i64 = match self.dbrelay.last_success_at { + Some(u) => u as i64, + None => 0, + }; + // Subtract overlap to avoid gaps due to clock sync and event // propogation delay special_since -= overlap as i64;