use crate::model::AccountTreeNode;
use crate::{export::Export, kernel::Settings, model::TxnSet, tackler};
use std::sync::Arc;
use std::{collections::BTreeSet, io};
pub struct AccountsExporter {}
impl Export for AccountsExporter {
fn write_export<W: io::Write + ?Sized>(
&self,
_cfg: &Settings,
writer: &mut W,
txn_data: &TxnSet<'_>,
) -> Result<(), tackler::Error> {
let mut accounts: BTreeSet<Arc<AccountTreeNode>> = BTreeSet::new();
for txn in &txn_data.txns {
for post in &txn.posts {
accounts.insert(post.acctn.atn.clone());
}
}
writeln!(writer, "accounts = [")?;
for i in accounts {
writeln!(writer, " \"{i}\",")?;
}
writeln!(writer, "]")?;
Ok(())
}
}