---
# System prepended metadata

title: KERI (current) out-of-order evenst state re-calculation
tags: [out_of_order]

---

# KERI (current) 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
    
    if (**self.apply_to_state([M]))**) then (Ok)
        :verify event signatures;
        :add to **kel finalized events** table;
        :return Ok(new_state);
        stop
    else (Error)
        :match Error;
        split
            :Error::EventOutOfOrder 
            -> add to **outoforder** table;
        split again
            :Error::NotEnoughSigs
            -> add to **partialy signed** table;
        split again
            :Error::EventDuplicate
            -> add to **duplicious events** table;
        endsplit
        :return Error;
        stop
@enduml
```