Skip to content

Commit

Permalink
chore: do not update datum channel if not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
cfcosta committed Aug 31, 2023
1 parent 97f5066 commit 4c79e80
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cmd/mine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,16 @@ pub async fn exec() -> miette::Result<()> {
.await
.into_diagnostic()?;

let mut last_value = None;

loop {
match get_latest_datum(&ledger_client).await {
Ok(d) => sender.send(Some(d)).into_diagnostic()?,
Ok(d) => {
if Some(&d) != last_value.as_ref() {
sender.send(Some(d.clone())).into_diagnostic()?;
last_value = Some(d);
}
}
Err(_) => {
tokio::time::sleep(Duration::from_secs(10)).await;
}
Expand Down

0 comments on commit 4c79e80

Please sign in to comment.