Skip to content

Commit

Permalink
chore: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolk131 committed Sep 14, 2024
1 parent 389dc96 commit 131437e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ nostr-sdk = "0.30.0"
palette = "0.7.6"
secp256k1 = { version = "0.28.2", features = ["global-context"] }
tokio = "1.40.0"
tokio-stream = "0.1.16"
tracing-subscriber = "0.3.18"

[dev-dependencies]
Expand Down
31 changes: 9 additions & 22 deletions src/fedimint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,16 @@ impl Wallet {
) -> Pin<Box<dyn iced::futures::Stream<Item = BTreeMap<FederationId, FederationView>> + Send>>
{
let clients = self.clients.clone();
Box::pin(async_stream::stream! {
let mut last_state_or = None;
loop {
let current_state = Self::get_current_state(clients.lock().await).await;

// Ignoring clippy lint here since the `match` provides better clarity.
#[allow(clippy::option_if_let_else)]
let has_changed = match &last_state_or {
Some(last_state) => {
&current_state != last_state
}
// If there was no last state, the state has changed.
None => true,
};

if has_changed {
last_state_or = Some(current_state.clone());
yield current_state;
}

tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
})
Box::pin(
tokio_stream::wrappers::IntervalStream::new(tokio::time::interval(
std::time::Duration::from_secs(1),
))
.then(move |_| {
let clients = clients.clone();
async move { Self::get_current_state(clients.lock().await).await }
}),
)
}

pub async fn connect_to_joined_federations(&self) -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() -> iced::Result {
level: iced::window::Level::Normal,
icon: None, // TODO: Set icon.
platform_specific: PlatformSpecific::default(), // TODO: Set platform specific settings for each platform.
exit_on_close_request: true,
exit_on_close_request: false,
})
.run()
}
Expand Down

0 comments on commit 131437e

Please sign in to comment.