From 6caca441d55ff73a9f1b8c6a8708f45fc367954b Mon Sep 17 00:00:00 2001 From: djing chan Date: Tue, 19 Dec 2023 14:52:26 +0700 Subject: [PATCH] We get the listeners calls when data got added to the stores. The duplicated listener calls have been redundant and caused issues on the clients (e.g. creating simultaneously 2 outbound connections) --- .../p2p/services/data/DataService.java | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/network/network/src/main/java/bisq/network/p2p/services/data/DataService.java b/network/network/src/main/java/bisq/network/p2p/services/data/DataService.java index da031709f2..e90c144410 100644 --- a/network/network/src/main/java/bisq/network/p2p/services/data/DataService.java +++ b/network/network/src/main/java/bisq/network/p2p/services/data/DataService.java @@ -150,11 +150,6 @@ public CompletableFuture addAuthenticatedData(AuthenticatedData AddAuthenticatedDataRequest request = AddAuthenticatedDataRequest.from(store, authenticatedData, keyPair); DataStorageResult dataStorageResult = store.add(request); if (dataStorageResult.isSuccess()) { - if (authenticatedData instanceof AuthorizedData) { - listeners.forEach(e -> e.onAuthorizedDataAdded((AuthorizedData) authenticatedData)); - } else { - listeners.forEach(e -> e.onAuthenticatedDataAdded(authenticatedData)); - } return new BroadcastResult(broadcasters.stream().map(broadcaster -> broadcaster.broadcast(request))); } else { return new BroadcastResult(); @@ -176,7 +171,6 @@ public CompletableFuture addAppendOnlyData(AppendOnlyData appen AddAppendOnlyDataRequest request = new AddAppendOnlyDataRequest(appendOnlyData); DataStorageResult dataStorageResult = store.add(request); if (dataStorageResult.isSuccess()) { - listeners.forEach(listener -> listener.onAppendOnlyDataAdded(appendOnlyData)); return new BroadcastResult(broadcasters.stream().map(broadcaster -> broadcaster.broadcast(request))); } else { return new BroadcastResult(); @@ -193,7 +187,6 @@ public CompletableFuture addMailboxData(MailboxData mailboxData AddMailboxRequest request = AddMailboxRequest.from(mailboxData, senderKeyPair, receiverPublicKey); DataStorageResult dataStorageResult = store.add(request); if (dataStorageResult.isSuccess()) { - listeners.forEach(listener -> listener.onMailboxDataAdded(mailboxData)); return new BroadcastResult(broadcasters.stream().map(broadcaster -> broadcaster.broadcast(request))); } else { return new BroadcastResult(); @@ -218,11 +211,6 @@ public CompletableFuture removeAuthenticatedData(AuthenticatedD RemoveAuthenticatedDataRequest request = RemoveAuthenticatedDataRequest.from(store, authenticatedData, keyPair); DataStorageResult dataStorageResult = store.remove(request); if (dataStorageResult.isSuccess()) { - if (authenticatedData instanceof AuthorizedData) { - listeners.forEach(e -> e.onAuthorizedDataRemoved((AuthorizedData) authenticatedData)); - } else { - listeners.forEach(e -> e.onAuthenticatedDataRemoved(authenticatedData)); - } return new BroadcastResult(broadcasters.stream().map(broadcaster -> broadcaster.broadcast(request))); } else { return new BroadcastResult(); @@ -245,7 +233,6 @@ public CompletableFuture removeMailboxData(MailboxData mailboxD RemoveMailboxRequest request = RemoveMailboxRequest.from(mailboxData, keyPair); DataStorageResult dataStorageResult = store.remove(request); if (dataStorageResult.isSuccess()) { - listeners.forEach(listener -> listener.onMailboxDataRemoved(mailboxData)); return new BroadcastResult(broadcasters.stream().map(broadcaster -> broadcaster.broadcast(request))); } else { return new BroadcastResult(); @@ -287,18 +274,6 @@ public void processAddDataRequest(AddDataRequest addDataRequest, boolean allowRe storageService.onAddDataRequest(addDataRequest) .whenComplete((optionalData, throwable) -> { optionalData.ifPresent(storageData -> { - // We get called on dispatcher thread with onMessage, and we don't switch thread in - // async calls - - if (storageData instanceof AuthorizedData) { - listeners.forEach(e -> e.onAuthorizedDataAdded((AuthorizedData) storageData)); - } else if (storageData instanceof AuthenticatedData) { - listeners.forEach(e -> e.onAuthenticatedDataAdded((AuthenticatedData) storageData)); - } else if (storageData instanceof MailboxData) { - listeners.forEach(listener -> listener.onMailboxDataAdded((MailboxData) storageData)); - } else if (storageData instanceof AppendOnlyData) { - listeners.forEach(listener -> listener.onAppendOnlyDataAdded((AppendOnlyData) storageData)); - } if (allowReBroadcast) { broadcasters.forEach(e -> e.reBroadcast(addDataRequest)); } @@ -310,13 +285,6 @@ public void processRemoveDataRequest(RemoveDataRequest removeDataRequest, boolea storageService.onRemoveDataRequest(removeDataRequest) .whenComplete((optionalData, throwable) -> { optionalData.ifPresent(storageData -> { - // We get called on dispatcher thread with onMessage, and we don't switch thread in - // async calls - if (storageData instanceof AuthorizedData) { - listeners.forEach(e -> e.onAuthorizedDataRemoved((AuthorizedData) storageData)); - } else if (storageData instanceof AuthenticatedData) { - listeners.forEach(e -> e.onAuthenticatedDataRemoved((AuthenticatedData) storageData)); - } if (allowReBroadcast) { broadcasters.forEach(e -> e.reBroadcast(removeDataRequest)); }