mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-24 17:49:07 -05:00
refactor: event is_ephemeral method
This commit is contained in:
parent
25752abe6b
commit
5c07b2eca5
|
@ -212,9 +212,9 @@ pub async fn db_writer(
|
|||
}
|
||||
// TODO: cache recent list of authors to remove a DB call.
|
||||
let start = Instant::now();
|
||||
if event.kind >= 20000 && event.kind < 30000 {
|
||||
if event.is_ephemeral() {
|
||||
bcast_tx.send(event.clone()).ok();
|
||||
info!(
|
||||
debug!(
|
||||
"published ephemeral event: {:?} from: {:?} in: {:?}",
|
||||
event.get_event_id_prefix(),
|
||||
event.get_author_prefix(),
|
||||
|
|
|
@ -120,6 +120,11 @@ impl Event {
|
|||
self.kind == 0
|
||||
}
|
||||
|
||||
/// Should this event be persisted?
|
||||
#[must_use] pub fn is_ephemeral(&self) -> bool {
|
||||
self.kind >= 20000 && self.kind < 30000
|
||||
}
|
||||
|
||||
/// Should this event be replaced with newer timestamps from same author?
|
||||
#[must_use] pub fn is_replaceable(&self) -> bool {
|
||||
self.kind == 0 || self.kind == 3 || self.kind == 41 || (self.kind >= 10000 && self.kind < 20000)
|
||||
|
|
Loading…
Reference in New Issue
Block a user