- let unannounced_rows = client.query("SELECT blob_signed, seen FROM (SELECT DISTINCT ON (short_channel_id) short_channel_id, blob_signed, seen FROM channel_updates ORDER BY short_channel_id ASC, seen ASC) AS first_seens WHERE first_seens.seen >= $1", &[&last_sync_timestamp_object]).await.unwrap();
- for current_row in unannounced_rows {
-
+ let newer_oldest_directional_updates = client.query("
+ SELECT DISTINCT ON (short_channel_id) *
+ FROM (
+ SELECT DISTINCT ON (short_channel_id, direction) blob_signed
+ FROM channel_updates
+ WHERE short_channel_id = any($1)
+ ORDER BY seen ASC, short_channel_id ASC, direction ASC
+ ) AS directional_last_seens
+ ORDER BY short_channel_id ASC, seen DESC
+ ", &[&channel_ids]).await.unwrap();
+
+ for current_row in newer_oldest_directional_updates {