Use connection.getPeersNodeAddressOptional().isPresent() instead of connection.hasPeersNodeAddress() which does the same internally

This commit is contained in:
chimp1984 2020-10-07 18:47:43 -05:00
parent 0686079946
commit 31ce5ccf67
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -271,8 +271,8 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
} }
public boolean isSeedNode(Connection connection) { public boolean isSeedNode(Connection connection) {
//TODO return connection.getPeersNodeAddressOptional().isPresent() &&
return connection.hasPeersNodeAddress() && seedNodeAddresses.contains(connection.getPeersNodeAddressOptional().get()); seedNodeAddresses.contains(connection.getPeersNodeAddressOptional().get());
} }
public boolean isSelf(NodeAddress nodeAddress) { public boolean isSelf(NodeAddress nodeAddress) {
@ -306,6 +306,7 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
// Peer // Peer
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("unused")
public Optional<Peer> findPeer(NodeAddress peersNodeAddress) { public Optional<Peer> findPeer(NodeAddress peersNodeAddress) {
return getAllPeers().stream() return getAllPeers().stream()
.filter(peer -> peer.getNodeAddress().equals(peersNodeAddress)) .filter(peer -> peer.getNodeAddress().equals(peersNodeAddress))