Skip to content

Commit d930f16

Browse files
committed
feat(nostr_manager): add signer lock to nostr manager
1 parent e7ec5ba commit d930f16

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/nostr_manager/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub struct NostrManager {
5555
session_salt: [u8; 16],
5656
timeout: Duration,
5757
pub(crate) event_tracker: std::sync::Arc<dyn EventTracker>,
58+
signer_lock: std::sync::Arc<tokio::sync::Mutex<()>>,
5859
// blossom: BlossomClient,
5960
}
6061

@@ -181,6 +182,7 @@ impl NostrManager {
181182
session_salt,
182183
timeout,
183184
event_tracker,
185+
signer_lock: std::sync::Arc::new(tokio::sync::Mutex::new(())),
184186
})
185187
}
186188

@@ -193,6 +195,7 @@ impl NostrManager {
193195
F: FnOnce() -> Fut,
194196
Fut: std::future::Future<Output = Result<T>> + Send,
195197
{
198+
let _guard = self.signer_lock.lock().await;
196199
self.client.set_signer(signer).await;
197200
let result = f().await;
198201
self.client.unset_signer().await;

0 commit comments

Comments
 (0)