use anyhow::Result;
use crate::context::WalletContext;
use crate::services_env;
use crate::tracker_host::{self, SystemClock, TickOptions};
pub async fn run(ctx: &WalletContext) -> Result<()> {
services_env::require_chain_tracker_to_prove(
"tracker-tick",
ctx.wallet.services().chaintracks.is_some(),
)?;
let mut report = tracker_host::tick(
ctx.wallet.storage(),
ctx.wallet.services(),
&SystemClock,
&TickOptions::from_env(),
)
.await?;
tracker_host::record_accepted(&ctx.wallet, &mut report).await;
if ctx.json_output {
println!("{}", serde_json::to_string(&report)?);
return Ok(());
}
println!("{}", report.summary());
for txid in &report.mined {
println!(" mined: {txid}");
}
for txid in &report.reannounced {
println!(" announced: {txid} (accepted on a re-announce)");
}
for txid in &report.not_final {
println!(" not final: {txid} (announced again after a pause)");
}
for txid in &report.no_proof {
println!(" no proof: {txid} (asked again after its pause)");
}
for txid in &report.moved {
println!(" moved: {txid} (its stored path left the active chain)");
}
for line in &report.stored {
println!(" storage: {line}");
}
for line in &report.faults {
println!(" fault: {line}");
}
Ok(())
}