mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +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::relationship::Relationship;
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::signer::Signer;
|
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 rusqlite::Connection;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
@ -40,10 +40,6 @@ pub struct Globals {
|
|||||||
/// All relationships between events
|
/// All relationships between events
|
||||||
pub relationships: RwLock<HashMap<Id, Vec<(Id, Relationship)>>>,
|
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
|
/// 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.
|
/// get them. We may already have these, but if not we should ask for them.
|
||||||
pub desired_events: RwLock<HashMap<Id, Vec<Url>>>,
|
pub desired_events: RwLock<HashMap<Id, Vec<Url>>>,
|
||||||
@ -97,7 +93,6 @@ lazy_static! {
|
|||||||
events: RwLock::new(HashMap::new()),
|
events: RwLock::new(HashMap::new()),
|
||||||
incoming_events: RwLock::new(Vec::new()),
|
incoming_events: RwLock::new(Vec::new()),
|
||||||
relationships: RwLock::new(HashMap::new()),
|
relationships: RwLock::new(HashMap::new()),
|
||||||
last_reply: RwLock::new(HashMap::new()),
|
|
||||||
desired_events: RwLock::new(HashMap::new()),
|
desired_events: RwLock::new(HashMap::new()),
|
||||||
people: RwLock::new(People::new()),
|
people: RwLock::new(People::new()),
|
||||||
relays: RwLock::new(HashMap::new()),
|
relays: RwLock::new(HashMap::new()),
|
||||||
@ -227,18 +222,6 @@ impl Globals {
|
|||||||
.or_insert_with(|| vec![r]);
|
.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> {
|
pub fn get_replies_sync(id: Id) -> Vec<Id> {
|
||||||
let mut output: Vec<Id> = Vec::new();
|
let mut output: Vec<Id> = Vec::new();
|
||||||
if let Some(vec) = GLOBALS.relationships.blocking_read().get(&id) {
|
if let Some(vec) = GLOBALS.relationships.blocking_read().get(&id) {
|
||||||
|
@ -141,18 +141,6 @@ pub async fn process_new_event(
|
|||||||
|
|
||||||
// Insert into relationships
|
// Insert into relationships
|
||||||
Globals::add_relationship(id, event.id, Relationship::Reply).await;
|
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
|
// We desire all ancestors
|
||||||
|
Loading…
Reference in New Issue
Block a user