X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Flookup.rs;h=5969b2a10bdbb0727f39c7a7a297c18a810fc02b;hb=e004a953d43654c14fef698d14e5aee2497dbcc4;hp=8018e5ca19d62a5b564b9f40a777f2aad18100b3;hpb=d4d5b73a49d7bf4e58c183d8ae407519f9bef22e;p=rapid-gossip-sync-server diff --git a/src/lookup.rs b/src/lookup.rs index 8018e5c..5969b2a 100644 --- a/src/lookup.rs +++ b/src/lookup.rs @@ -209,14 +209,17 @@ pub(super) async fn fetch_channel_updates(delta_set: &mut DeltaSet, client: &Cli // there was an update in either direction that happened after the last sync (to avoid // collecting too many reference updates) let reference_rows = client.query(" - SELECT DISTINCT ON (short_channel_id, direction) id, direction, blob_signed - FROM channel_updates - WHERE seen < $1 AND short_channel_id IN ( + SELECT id, direction, blob_signed FROM channel_updates + WHERE id IN ( + SELECT DISTINCT ON (short_channel_id, direction) 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 ) - ORDER BY short_channel_id ASC, direction ASC, seen DESC ", &[&last_sync_timestamp_object]).await.unwrap(); println!("Fetched reference rows ({}): {:?}", reference_rows.len(), start.elapsed());