mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Combine if/else branches. Improve comments and variables
This commit is contained in:
parent
bc802c861d
commit
f7951d5943
@ -289,18 +289,14 @@ public class BroadcastHandler implements PeerManager.Listener {
|
|||||||
.map(Broadcaster.BroadcastRequest::getListener)
|
.map(Broadcaster.BroadcastRequest::getListener)
|
||||||
.forEach(listener -> listener.onSufficientlyBroadcast(broadcastRequests));
|
.forEach(listener -> listener.onSufficientlyBroadcast(broadcastRequests));
|
||||||
} else {
|
} else {
|
||||||
// Number of open requests to peers is less than we need to reach numOfCompletedBroadcastsTarget.
|
// We check if number of open requests to peers is less than we need to reach numOfCompletedBroadcastsTarget.
|
||||||
// Thus we never can reach required resilience as too many numOfFailedBroadcasts occurred.
|
// Thus we never can reach required resilience as too many numOfFailedBroadcasts occurred.
|
||||||
int openRequests = numPeersForBroadcast - numOfCompletedBroadcasts - numOfFailedBroadcasts;
|
int maxPossibleSuccessCases = numPeersForBroadcast - numOfFailedBroadcasts;
|
||||||
int maxPossibleSuccessCases = openRequests + numOfCompletedBroadcasts;
|
|
||||||
// We subtract 1 as we want to have it called only once, with a < comparision we would trigger repeatedly.
|
// We subtract 1 as we want to have it called only once, with a < comparision we would trigger repeatedly.
|
||||||
if (maxPossibleSuccessCases == numOfCompletedBroadcastsTarget - 1) {
|
boolean notEnoughSucceededOrOpen = maxPossibleSuccessCases == numOfCompletedBroadcastsTarget - 1;
|
||||||
broadcastRequests.stream()
|
// We did not reach resilience level and timeout prevents to reach it later
|
||||||
.filter(broadcastRequest -> broadcastRequest.getListener() != null)
|
boolean timeoutAndNotEnoughSucceeded = timeoutTriggered && numOfCompletedBroadcasts < numOfCompletedBroadcastsTarget;
|
||||||
.map(Broadcaster.BroadcastRequest::getListener)
|
if (notEnoughSucceededOrOpen || timeoutAndNotEnoughSucceeded) {
|
||||||
.forEach(listener -> listener.onNotSufficientlyBroadcast(numOfCompletedBroadcasts, numOfFailedBroadcasts));
|
|
||||||
} else if (timeoutTriggered && numOfCompletedBroadcasts < numOfCompletedBroadcastsTarget) {
|
|
||||||
// We did not reach resilience level and timeout prevents to reach it later
|
|
||||||
broadcastRequests.stream()
|
broadcastRequests.stream()
|
||||||
.filter(broadcastRequest -> broadcastRequest.getListener() != null)
|
.filter(broadcastRequest -> broadcastRequest.getListener() != null)
|
||||||
.map(Broadcaster.BroadcastRequest::getListener)
|
.map(Broadcaster.BroadcastRequest::getListener)
|
||||||
|
Loading…
Reference in New Issue
Block a user