Skip to content

Commit 84c2330

Browse files
authored
Merge pull request #56 from nodetec/cleanup
refactor: NostrModule::get_state() takes self as arg
2 parents b844ad4 + c121c46 commit 84c2330

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/nostr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl NostrModule {
4646
pub fn subscription(&self) -> Subscription<NostrState> {
4747
const POLL_DURATION: Duration = Duration::from_millis(200);
4848

49-
let client = self.client.clone();
49+
let self_clone = self.clone();
5050

5151
Subscription::run_with_id(
5252
std::any::TypeId::of::<NostrState>(),
@@ -57,7 +57,7 @@ impl NostrModule {
5757
async_stream::stream! {
5858
let mut last_state = NostrState::default();
5959
loop {
60-
let new_state = Self::get_state(&client).await;
60+
let new_state = self_clone.get_state().await;
6161
if new_state != last_state {
6262
yield new_state.clone();
6363
last_state = new_state;
@@ -72,10 +72,10 @@ impl NostrModule {
7272
/// Fetches the current state of the Nostr SDK client.
7373
/// Note: This is async because it's grabbing read locks
7474
/// on the relay `RwLock`s. No network requests are made.
75-
async fn get_state(client: &nostr_sdk::Client) -> NostrState {
75+
async fn get_state(&self) -> NostrState {
7676
let mut relay_connections = BTreeMap::new();
7777

78-
for (url, relay) in client.relays().await {
78+
for (url, relay) in self.client.relays().await {
7979
relay_connections.insert(url.clone(), relay.status().await);
8080
}
8181

0 commit comments

Comments
 (0)