# KERI (single table) out-of-order evenst state re-calculation ###### tags: `out_of_order` ```plantuml @startuml start :new message [M] processing; if (Dip or Drt) then (true) if (validate_seal()) then (false) if (Error::EventOutOfOrder) then (true) :add to **out of order** table; else (false) endif :return Err; stop else (true) endif else (false) endif :add [M] to **kel finalized events** table; note If at this stage all prev out-of-order events were in **kel finalized events** they'll be re-calculated in one go by **calculate_state()** or ignored if remain out-of-order endnote note right change of **calculate_state** required should ignore out_of_order events endnote if (**self.apply_to_state([M]))**) then (Ok) :verify event signatures; :return Ok(new_state); stop else (Error) :match Error; split :Error::EventOutOfOrder -> do nothing - already in the DB; split again :Error::NotEnoughSigs -> add [M] to **partialy signed** table remove [M] from **kel finalized events**; note right I dont like this Should be in same table too? endnote split again :Error::EventDuplicate -> add [M] to **duplicious events** table remove [M] from **kel finalized events**; note right I dont like this Should be in same table too? endnote endsplit :return Error; stop @enduml ```