diff --git a/src/Angor/Shared/Services/INostrCommunicationFactory.cs b/src/Angor/Shared/Services/INostrCommunicationFactory.cs index b4c2c9fb..d2f2089a 100644 --- a/src/Angor/Shared/Services/INostrCommunicationFactory.cs +++ b/src/Angor/Shared/Services/INostrCommunicationFactory.cs @@ -8,7 +8,7 @@ public interface INostrCommunicationFactory void CloseClientConnection(); int GetNumberOfRelaysConnected(); bool EoseEventReceivedOnAllRelays(string subscription); - void MonitoringEoseReceivedOnSubscription(string subscription); + bool MonitoringEoseReceivedOnSubscription(string subscription); void ClearEoseReceivedOnSubscriptionMonitoring(string subscription); bool OkEventReceivedOnAllRelays(string eventId); void MonitoringOkReceivedOnSubscription(string eventId); diff --git a/src/Angor/Shared/Services/NostrCommunicationFactory.cs b/src/Angor/Shared/Services/NostrCommunicationFactory.cs index 83112a27..3e3be8be 100644 --- a/src/Angor/Shared/Services/NostrCommunicationFactory.cs +++ b/src/Angor/Shared/Services/NostrCommunicationFactory.cs @@ -114,10 +114,10 @@ public bool EoseEventReceivedOnAllRelays(string subscription) return response; } - public void MonitoringEoseReceivedOnSubscription(string subscription) + public bool MonitoringEoseReceivedOnSubscription(string subscription) { _logger.LogInformation($"Started monitoring subscription {subscription}"); - _eoseCalledOnSubscriptionClients.Add(subscription, new List()); + return _eoseCalledOnSubscriptionClients.TryAdd(subscription, new List()); } public void ClearEoseReceivedOnSubscriptionMonitoring(string subscription) diff --git a/src/Angor/Shared/Services/RelaySubscriptionsHandling.cs b/src/Angor/Shared/Services/RelaySubscriptionsHandling.cs index 6870e1c0..ddd7e7de 100644 --- a/src/Angor/Shared/Services/RelaySubscriptionsHandling.cs +++ b/src/Angor/Shared/Services/RelaySubscriptionsHandling.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using Blockcore.EventBus; using Microsoft.Extensions.Logging; using Nostr.Client.Requests; using Nostr.Client.Responses; @@ -65,9 +66,12 @@ public void HandleOkMessages(NostrOkResponse okResponse) public bool TryAddEoseAction(string subscriptionName, Action action) { - _communicationFactory.MonitoringEoseReceivedOnSubscription(subscriptionName); - - return userEoseActions.TryAdd(subscriptionName,action); + var add = _communicationFactory.MonitoringEoseReceivedOnSubscription(subscriptionName); + + if (!add) + _logger.LogWarning($"Subscription {subscriptionName} is already being monitored"); + + return userEoseActions.TryAdd(subscriptionName,action); } public void HandleEoseMessages(NostrEoseResponse _)