use std::collections::{BTreeMap, HashSet};
use std::io::Cursor;
-use std::ops::Add;
+use std::ops::{Add, Deref};
use std::sync::Arc;
use std::time::{Duration, Instant, SystemTime};
use tokio_postgres::tls::NoTlsStream;
use futures::StreamExt;
+use lightning::util::logger::Logger;
-use crate::{config, TestLogger};
+use crate::config;
use crate::serialization::MutatedProperties;
/// The delta set needs to be a BTreeMap so the keys are sorted.
/// whether they had been seen before.
/// Also include all announcements for which the first update was announced
/// after `last_sync_timestamp`
-pub(super) async fn fetch_channel_announcements(delta_set: &mut DeltaSet, network_graph: Arc<NetworkGraph<TestLogger>>, client: &Client, last_sync_timestamp: u32) {
+pub(super) async fn fetch_channel_announcements<L: Deref>(delta_set: &mut DeltaSet, network_graph: Arc<NetworkGraph<L>>, client: &Client, last_sync_timestamp: u32) where L::Target: Logger {
println!("Obtaining channel ids from network graph");
let last_sync_timestamp_object = SystemTime::UNIX_EPOCH.add(Duration::from_secs(last_sync_timestamp as u64));
let channel_ids = {
WHERE id IN (
SELECT DISTINCT ON (short_channel_id, direction) id
FROM channel_updates
- WHERE seen < $1
+ WHERE seen < $1 AND short_channel_id IN (
+ SELECT DISTINCT ON (short_channel_id) short_channel_id
+ FROM channel_updates
+ WHERE seen >= $1
+ )
ORDER BY short_channel_id ASC, direction ASC, seen DESC
- ) AND short_channel_id IN (
- SELECT DISTINCT ON (short_channel_id) short_channel_id
- FROM channel_updates
- WHERE seen >= $1
)
", [last_sync_timestamp_object]).await.unwrap();
let mut pinned_rows = Box::pin(reference_rows);