mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 03:33:53 +00:00
Remove globals.last_reply, we no longer need it
This commit is contained in:
parent
611b5ab12c
commit
d03cf859e1
@ -7,7 +7,7 @@ use crate::people::People;
|
||||
use crate::relationship::Relationship;
|
||||
use crate::settings::Settings;
|
||||
use crate::signer::Signer;
|
||||
use nostr_types::{Event, Id, IdHex, PublicKeyHex, Unixtime, Url};
|
||||
use nostr_types::{Event, Id, IdHex, PublicKeyHex, Url};
|
||||
use rusqlite::Connection;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
@ -40,10 +40,6 @@ pub struct Globals {
|
||||
/// All relationships between events
|
||||
pub relationships: RwLock<HashMap<Id, Vec<(Id, Relationship)>>>,
|
||||
|
||||
/// The date of the latest reply. Only reply relationships count, not reactions,
|
||||
/// deletions, or quotes
|
||||
pub last_reply: RwLock<HashMap<Id, Unixtime>>,
|
||||
|
||||
/// Desired events, referred to by others, with possible URLs where we can
|
||||
/// get them. We may already have these, but if not we should ask for them.
|
||||
pub desired_events: RwLock<HashMap<Id, Vec<Url>>>,
|
||||
@ -97,7 +93,6 @@ lazy_static! {
|
||||
events: RwLock::new(HashMap::new()),
|
||||
incoming_events: RwLock::new(Vec::new()),
|
||||
relationships: RwLock::new(HashMap::new()),
|
||||
last_reply: RwLock::new(HashMap::new()),
|
||||
desired_events: RwLock::new(HashMap::new()),
|
||||
people: RwLock::new(People::new()),
|
||||
relays: RwLock::new(HashMap::new()),
|
||||
@ -227,18 +222,6 @@ impl Globals {
|
||||
.or_insert_with(|| vec![r]);
|
||||
}
|
||||
|
||||
pub async fn update_last_reply(id: Id, time: Unixtime) {
|
||||
let mut last_reply = GLOBALS.last_reply.write().await;
|
||||
last_reply
|
||||
.entry(id)
|
||||
.and_modify(|lasttime| {
|
||||
if time > *lasttime {
|
||||
*lasttime = time;
|
||||
}
|
||||
})
|
||||
.or_insert_with(|| time);
|
||||
}
|
||||
|
||||
pub fn get_replies_sync(id: Id) -> Vec<Id> {
|
||||
let mut output: Vec<Id> = Vec::new();
|
||||
if let Some(vec) = GLOBALS.relationships.blocking_read().get(&id) {
|
||||
|
@ -141,18 +141,6 @@ pub async fn process_new_event(
|
||||
|
||||
// Insert into relationships
|
||||
Globals::add_relationship(id, event.id, Relationship::Reply).await;
|
||||
|
||||
// Update last_reply
|
||||
let mut id = id;
|
||||
Globals::update_last_reply(id, event.created_at).await;
|
||||
while let Some(ev) = GLOBALS.events.read().await.get(&id).cloned() {
|
||||
if let Some((pid, _)) = ev.replies_to() {
|
||||
id = pid;
|
||||
Globals::update_last_reply(id, event.created_at).await;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We desire all ancestors
|
||||
|
Loading…
Reference in New Issue
Block a user