use std::time::Instant;
use brk_types::{Transaction, Txid};
use crate::{TxEntry, TxRemoval};
pub struct TxTombstone {
pub tx: Transaction,
pub entry: TxEntry,
removal: TxRemoval,
removed_at: Instant,
}
impl TxTombstone {
pub(crate) fn new(
tx: Transaction,
entry: TxEntry,
removal: TxRemoval,
removed_at: Instant,
) -> Self {
Self {
tx,
entry,
removal,
removed_at,
}
}
pub fn reason(&self) -> &TxRemoval {
&self.removal
}
pub(crate) fn removed_at(&self) -> Instant {
self.removed_at
}
pub(crate) fn replaced_by(&self) -> Option<&Txid> {
match &self.removal {
TxRemoval::Replaced { by } => Some(by),
TxRemoval::Vanished => None,
}
}
}