|
1 | 1 | use rostra_core::event::{EventExt as _, VerifiedEvent, VerifiedEventContent}; |
2 | 2 | use rostra_core::id::ToShort as _; |
| 3 | +use rostra_core::ContentHash; |
3 | 4 | use rostra_util_error::FmtCompact as _; |
4 | 5 | use tracing::{info, warn}; |
5 | 6 |
|
@@ -110,31 +111,32 @@ impl Database { |
110 | 111 | } |
111 | 112 | } |
112 | 113 |
|
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 |
124 | 123 | } 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 |
135 | 136 | } |
136 | 137 | } |
137 | | - }; |
| 138 | + } |
| 139 | + }; |
138 | 140 |
|
139 | 141 | if process_event_content_state == ProcessEventState::New { |
140 | 142 | events_content_missing_tbl.insert(&event.event_id.to_short(), &())?; |
|
0 commit comments