Renamed hasCapabilities to isEmpty

This commit is contained in:
Florian Reimair 2019-03-18 12:17:34 +01:00
parent ede3a3c721
commit afc241c52a
No known key found for this signature in database
GPG Key ID: 7EA8CA324B6E5633
4 changed files with 7 additions and 7 deletions

View File

@ -83,8 +83,8 @@ public class Capabilities {
return containsAll(capabilities.capabilities);
}
public boolean hasCapabilities() {
return !capabilities.isEmpty();
public boolean isEmpty() {
return capabilities.isEmpty();
}

View File

@ -619,7 +619,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
// it from old versions, so we filter those.
Optional<Peer> optionalPeer = allPeers.stream()
.filter(peer -> peer.getNodeAddress().equals(peersNodeAddress))
.filter(peer -> peer.getCapabilities().hasCapabilities())
.filter(peer -> !peer.getCapabilities().isEmpty())
.findAny();
if (optionalPeer.isPresent()) {
boolean result = optionalPeer.get().getCapabilities().containsAll(((CapabilityRequiringPayload) message).getRequiredCapabilities());

View File

@ -176,7 +176,7 @@ public class PeerManager implements ConnectionListener, PersistedDataHost {
PeerList persistedPeerList = storage.initAndGetPersistedWithFileName("PeerList", 1000);
if (persistedPeerList != null) {
long peersWithNoCapabilitiesSet = persistedPeerList.getList().stream()
.filter(e -> e.getCapabilities().hasCapabilities())
.filter(e -> e.getCapabilities().isEmpty())
.mapToInt(e -> 1)
.count();
if (peersWithNoCapabilitiesSet > 100) {
@ -664,11 +664,11 @@ public class PeerManager implements ConnectionListener, PersistedDataHost {
// If we have a new connection the supportedCapabilities is empty.
// We lookup if we have already stored the supportedCapabilities at the persisted or reported peers
// and if so we use that.
if (!supportedCapabilities.hasCapabilities()) {
if (supportedCapabilities.isEmpty()) {
Set<Peer> allPeers = new HashSet<>(getPersistedPeers());
allPeers.addAll(getReportedPeers());
Optional<Peer> ourPeer = allPeers.stream().filter(peer -> peer.getNodeAddress().equals(connection.getPeersNodeAddressOptional().get()))
.filter(peer -> !peer.getCapabilities().hasCapabilities())
.filter(peer -> !peer.getCapabilities().isEmpty())
.findAny();
if(ourPeer.isPresent())
supportedCapabilities = new Capabilities(ourPeer.get().getCapabilities());

View File

@ -97,7 +97,7 @@ public final class Peer implements HasCapabilities, NetworkPayload, PersistableP
@Override
public void onChanged(Capabilities supportedCapabilities) {
if (supportedCapabilities.hasCapabilities())
if (!supportedCapabilities.isEmpty())
capabilities.set(supportedCapabilities);
}