Skip to content

Commit 3664dd1

Browse files
committed
chore: skip no-content content
1 parent 30a5c12 commit 3664dd1

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

crates/rostra-client-db/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ pub enum ProcessEventState {
738738
Existing,
739739
Pruned,
740740
Deleted,
741+
NoContent,
741742
}
742743

743744
pub enum ContentWantState {
@@ -753,6 +754,7 @@ impl ProcessEventState {
753754
ProcessEventState::Existing => ContentWantState::MaybeWants,
754755
ProcessEventState::Pruned => ContentWantState::DoesNotWant,
755756
ProcessEventState::Deleted => ContentWantState::DoesNotWant,
757+
ProcessEventState::NoContent => ContentWantState::DoesNotWant,
756758
}
757759
}
758760
}

crates/rostra-client-db/src/process_event_ops.rs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rostra_core::event::{EventExt as _, VerifiedEvent, VerifiedEventContent};
22
use rostra_core::id::ToShort as _;
3+
use rostra_core::ContentHash;
34
use rostra_util_error::FmtCompact as _;
45
use tracing::{info, warn};
56

@@ -110,31 +111,32 @@ impl Database {
110111
}
111112
}
112113

113-
let process_event_content_state =
114-
if Self::MAX_CONTENT_LEN < u32::from(event.event.content_len) {
115-
if Database::prune_event_content_tx(
116-
event.event_id,
117-
&mut events_content_tbl,
118-
&mut events_content_missing_tbl,
119-
)? {
120-
ProcessEventState::Pruned
121-
} else {
122-
ProcessEventState::Deleted
123-
}
114+
let process_event_content_state = if event.event.content_hash() == ContentHash::ZERO {
115+
ProcessEventState::NoContent
116+
} else if Self::MAX_CONTENT_LEN < u32::from(event.event.content_len) {
117+
if Database::prune_event_content_tx(
118+
event.event_id,
119+
&mut events_content_tbl,
120+
&mut events_content_missing_tbl,
121+
)? {
122+
ProcessEventState::Pruned
124123
} else {
125-
match insert_event_outcome {
126-
InsertEventOutcome::AlreadyPresent => ProcessEventState::Existing,
127-
InsertEventOutcome::Inserted { is_deleted, .. } => {
128-
if is_deleted {
129-
ProcessEventState::Deleted
130-
} else {
131-
// If the event was not there, and it wasn't deleted
132-
// it definitely does not have content yet.
133-
ProcessEventState::New
134-
}
124+
ProcessEventState::Deleted
125+
}
126+
} else {
127+
match insert_event_outcome {
128+
InsertEventOutcome::AlreadyPresent => ProcessEventState::Existing,
129+
InsertEventOutcome::Inserted { is_deleted, .. } => {
130+
if is_deleted {
131+
ProcessEventState::Deleted
132+
} else {
133+
// If the event was not there, and it wasn't deleted
134+
// it definitely does not have content yet.
135+
ProcessEventState::New
135136
}
136137
}
137-
};
138+
}
139+
};
138140

139141
if process_event_content_state == ProcessEventState::New {
140142
events_content_missing_tbl.insert(&event.event_id.to_short(), &())?;

0 commit comments

Comments
 (0)