Skip to content

Commit

Permalink
feat(exex): ExExNotification::into_inverted (#11205)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin authored Sep 25, 2024
1 parent 1e0a35e commit 3d03451
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/exex/types/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ impl ExExNotification {
Self::ChainCommitted { .. } => None,
}
}

/// Converts the notification into a notification that is the inverse of the original one.
///
/// - For [`Self::ChainCommitted`], it's [`Self::ChainReverted`].
/// - For [`Self::ChainReverted`], it's [`Self::ChainCommitted`].
/// - For [`Self::ChainReorged`], it's [`Self::ChainReorged`] with the new chain as the old
/// chain and the old chain as the new chain.
pub fn into_inverted(self) -> Self {
match self {
Self::ChainCommitted { new } => Self::ChainReverted { old: new },
Self::ChainReverted { old } => Self::ChainCommitted { new: old },
Self::ChainReorged { old, new } => Self::ChainReorged { old: new, new: old },
}
}
}

impl From<CanonStateNotification> for ExExNotification {
Expand Down

0 comments on commit 3d03451

Please sign in to comment.