diff --git a/core/src/main/java/org/bitcoinj/core/Peer.java b/core/src/main/java/org/bitcoinj/core/Peer.java index e5ead5752..6cf546287 100644 --- a/core/src/main/java/org/bitcoinj/core/Peer.java +++ b/core/src/main/java/org/bitcoinj/core/Peer.java @@ -523,7 +523,7 @@ public class Peer extends PeerSocketHandler { // implementations claim to have a block chain in their services field but then report a height of zero, filter // them out here. Services services = peerVersionMessage.services(); - if (!(services.has(Services.NODE_NETWORK) || services.has(Services.NODE_NETWORK_LIMITED)) || + if (!services.anyOf(Services.NODE_NETWORK | Services.NODE_NETWORK_LIMITED) || (!params.allowEmptyPeerChain() && peerVersionMessage.bestHeight == 0)) { // Shut down the channel gracefully. log.info("{}: Peer does not have at least a recent part of the block chain.", this); diff --git a/core/src/main/java/org/bitcoinj/core/Services.java b/core/src/main/java/org/bitcoinj/core/Services.java index 02a7cac6f..4929f11df 100644 --- a/core/src/main/java/org/bitcoinj/core/Services.java +++ b/core/src/main/java/org/bitcoinj/core/Services.java @@ -107,12 +107,22 @@ public class Services { * Checks if given specific node services are signaled by this bitfield. * * @param bitmask bitmask representing the services to be checked for - * @return true if the given services are allsignaled, false otherwise + * @return true if the given services are all signaled, false otherwise */ public boolean has(long bitmask) { return (bits & bitmask) == bitmask; } + /** + * Checks if at least one of the given node services is signaled by this bitfield. + * + * @param bitmask bitmask representing the services to be checked for + * @return true if at least one of the given services is signaled, false otherwise + */ + public boolean anyOf(long bitmask) { + return (bits & bitmask) != 0; + } + /** * Write the node service bits into the given buffer. *