mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Modify 'since' computation when pulling from relays on startup
This commit is contained in:
parent
46281ca6e6
commit
0fa10a8e1c
@ -102,6 +102,7 @@ impl DbPersonRelay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch oldest last_fetched among a set of public keys for a relay
|
/// Fetch oldest last_fetched among a set of public keys for a relay
|
||||||
|
#[allow(dead_code)]
|
||||||
pub async fn fetch_oldest_last_fetched(
|
pub async fn fetch_oldest_last_fetched(
|
||||||
pubkeys: &[PublicKeyHex],
|
pubkeys: &[PublicKeyHex],
|
||||||
relay: &str,
|
relay: &str,
|
||||||
|
@ -3,7 +3,7 @@ mod handle_websocket;
|
|||||||
mod subscription;
|
mod subscription;
|
||||||
|
|
||||||
use crate::comms::BusMessage;
|
use crate::comms::BusMessage;
|
||||||
use crate::db::{DbPersonRelay, DbRelay};
|
use crate::db::DbRelay;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::globals::GLOBALS;
|
use crate::globals::GLOBALS;
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
@ -265,16 +265,26 @@ impl Minion {
|
|||||||
|
|
||||||
// Compute how far to look back
|
// Compute how far to look back
|
||||||
let (feed_since, special_since) = {
|
let (feed_since, special_since) = {
|
||||||
// Find the oldest 'last_fetched' among the 'person_relay' table.
|
// Get related settings
|
||||||
// Null values will come through as 0.
|
|
||||||
let mut special_since: i64 =
|
|
||||||
DbPersonRelay::fetch_oldest_last_fetched(&pubkeys, self.url.inner()).await? as i64;
|
|
||||||
|
|
||||||
let (overlap, feed_chunk) = {
|
let (overlap, feed_chunk) = {
|
||||||
let settings = GLOBALS.settings.read().await.clone();
|
let settings = GLOBALS.settings.read().await.clone();
|
||||||
(settings.overlap, settings.feed_chunk)
|
(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
|
// Subtract overlap to avoid gaps due to clock sync and event
|
||||||
// propogation delay
|
// propogation delay
|
||||||
special_since -= overlap as i64;
|
special_since -= overlap as i64;
|
||||||
|
Loading…
Reference in New Issue
Block a user