Skip to content

Commit

Permalink
fix: optimization to do less work
Browse files Browse the repository at this point in the history
the check should have been cid_map before too
  • Loading branch information
dav1do committed Jun 20, 2024
1 parent 5c23e68 commit 90379ed
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions service/src/event/ordering_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,16 @@ impl StreamEvents {
self.prev_map.insert(meta.prev, meta.cid);
if !self.should_process {
// we depend on something in memory
self.should_process = self.prev_map.contains_key(&meta.prev);
if let Some(in_memory_prev) = self.cid_map.get(&meta.prev) {
match in_memory_prev {
StreamEvent::InitEvent(_) | StreamEvent::KnownDeliverable(_) => {
self.should_process = true;
}
StreamEvent::Undelivered(_) => {
// nothing to do until it's prev arrives
}
}
}
}
meta.cid
}
Expand Down Expand Up @@ -544,7 +553,7 @@ mod test {
use ceramic_store::EventInsertable;
use test_log::test;

use crate::tests::get_n_events;
use crate::{tests::get_n_events, CeramicEventService};

use super::*;

Expand Down

0 comments on commit 90379ed

Please sign in to comment.