use std::fmt::{Display, Formatter};
use crate::internal::prelude::*;
use crate::primitive::prelude::*;
#[derive(Debug, Clone, strum::EnumTryAs, strum::EnumIs, strum::EnumDiscriminants)]
pub enum ChainEvent {
Announcement(AccountEntry),
ChannelOpened(ChannelEntry),
ChannelClosureInitiated(ChannelEntry),
ChannelClosed(ChannelEntry),
ChannelBalanceIncreased(ChannelEntry, HoprBalance),
ChannelBalanceDecreased(ChannelEntry, HoprBalance),
TicketRedeemed(ChannelEntry, Option<Box<VerifiedTicket>>),
WinningProbabilityIncreased(WinningProbability),
WinningProbabilityDecreased(WinningProbability),
TicketPriceChanged(HoprBalance),
}
impl Display for ChainEvent {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ChainEvent::Announcement(a) => write!(f, "announcement event of {a}"),
ChainEvent::ChannelOpened(c) => write!(f, "open channel event {}", c.get_id()),
ChainEvent::ChannelClosureInitiated(c) => {
write!(f, "close channel initiation event {}", c.get_id())
}
ChainEvent::ChannelClosed(c) => write!(f, "close channel event {}", c.get_id()),
ChainEvent::ChannelBalanceIncreased(c, _) => {
write!(f, "channel increase balance event {}", c.get_id())
}
ChainEvent::ChannelBalanceDecreased(c, _) => {
write!(f, "channel decrease balance event {}", c.get_id())
}
ChainEvent::TicketRedeemed(c, _) => {
write!(f, "ticket redeem event in channel {}", c.get_id())
}
ChainEvent::WinningProbabilityIncreased(p) => {
write!(f, "winning probability increased to {p}")
}
ChainEvent::WinningProbabilityDecreased(p) => {
write!(f, "winning probability decreased to {p}")
}
ChainEvent::TicketPriceChanged(p) => write!(f, "ticket price changed to {p}"),
}
}
}