From 8a03b89985e5aff56709d9205bbec9cc8b94090f Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 29 Sep 2019 16:49:02 +0100 Subject: [PATCH] clean up the filtering logic; allow serialization of hosts that can be retried --- .../main/groovy/com/muwire/core/hostcache/HostCache.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy b/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy index 27d01dbe..1c35aa85 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/HostCache.groovy @@ -82,6 +82,10 @@ class HostCache extends Service { List getHosts(int n) { List rv = new ArrayList<>(hosts.keySet()) rv.retainAll {allowHost(hosts[it])} + rv.removeAll { + def h = hosts[it]; + h.isFailed() && !h.canTryAgain() + } if (rv.size() <= n) return rv Collections.shuffle(rv) @@ -122,8 +126,6 @@ class HostCache extends Service { } private boolean allowHost(Host host) { - if (host.isFailed() && !host.canTryAgain()) - return false if (host.destination == myself) return false TrustLevel trust = trustService.getLevel(host.destination)