@@ -13,7 +13,7 @@ use std::time::Duration;
1313use async_utility:: futures_util:: stream:: { BoxStream , FuturesUnordered } ;
1414use nostr:: prelude:: * ;
1515use nostr_database:: prelude:: * ;
16- use nostr_gossip:: { BestRelaySelection , GossipListKind , NostrGossip } ;
16+ use nostr_gossip:: { BestRelaySelection , GossipListKind , GossipPublicKeyStatus , NostrGossip } ;
1717use nostr_relay_pool:: prelude:: * ;
1818use tokio:: sync:: { broadcast, Semaphore } ;
1919
@@ -1339,14 +1339,14 @@ impl Client {
13391339 where
13401340 I : IntoIterator < Item = PublicKey > ,
13411341 {
1342- let mut outdated_public_keys: HashSet < PublicKey > = HashSet :: new ( ) ;
1342+ let mut outdated_public_keys: HashMap < PublicKey , Timestamp > = HashMap :: new ( ) ;
13431343
13441344 for public_key in public_keys. into_iter ( ) {
13451345 // Get the public key status
13461346 let status = gossip. status ( & public_key, gossip_kind) . await ?;
13471347
1348- if status. is_outdated ( ) {
1349- outdated_public_keys. insert ( public_key) ;
1348+ if let GossipPublicKeyStatus :: Outdated { created_at } = status {
1349+ outdated_public_keys. insert ( public_key, created_at . unwrap_or_default ( ) ) ;
13501350 }
13511351 }
13521352
@@ -1363,7 +1363,7 @@ impl Client {
13631363
13641364 // Compose database filter
13651365 let db_filter: Filter = Filter :: default ( )
1366- . authors ( outdated_public_keys. clone ( ) )
1366+ . authors ( outdated_public_keys. keys ( ) . copied ( ) )
13671367 . kind ( kind) ;
13681368
13691369 // Get events from database
@@ -1387,9 +1387,7 @@ impl Client {
13871387 let mut futures = FuturesUnordered :: new ( ) ;
13881388
13891389 // Try to fetch from relays only the newer events (last created_at + 1)
1390- for event in stored_events. iter ( ) {
1391- let author = event. pubkey ;
1392- let created_at = event. created_at ;
1390+ for ( author, created_at) in outdated_public_keys. iter ( ) {
13931391 let urls = urls. clone ( ) ;
13941392 let semaphore = semaphore. clone ( ) ;
13951393
@@ -1399,9 +1397,9 @@ impl Client {
13991397
14001398 // Construct filter
14011399 let filter: Filter = Filter :: new ( )
1402- . author ( author)
1400+ . author ( * author)
14031401 . kind ( kind)
1404- . since ( created_at + Duration :: from_secs ( 1 ) )
1402+ . since ( * created_at + Duration :: from_secs ( 1 ) )
14051403 . limit ( 1 ) ;
14061404
14071405 // Fetch the event
@@ -1415,7 +1413,8 @@ impl Client {
14151413 }
14161414
14171415 // Keep track of the missing public keys
1418- let mut missing_public_keys: HashSet < PublicKey > = outdated_public_keys;
1416+ let mut missing_public_keys: HashSet < PublicKey > =
1417+ outdated_public_keys. keys ( ) . copied ( ) . collect ( ) ;
14191418
14201419 while let Some ( result) = futures. next ( ) . await {
14211420 if let Ok ( events) = result {
0 commit comments