Peer: Drop Bitcoin Cash peers early, based on service bit 5.

They will fail the difficulty check anyway.
This commit is contained in:
Andreas Schildbach 2017-08-22 10:22:52 +02:00
parent ff970f6fad
commit 738011a2a4
2 changed files with 9 additions and 0 deletions

View file

@ -564,6 +564,13 @@ public class Peer extends PeerSocketHandler {
close();
return;
}
if ((vPeerVersionMessage.localServices
& VersionMessage.NODE_BITCOIN_CASH) == VersionMessage.NODE_BITCOIN_CASH) {
log.info("{}: Peer follows an incompatible block chain.", this);
// Shut down the channel gracefully.
close();
return;
}
if (vPeerVersionMessage.bestHeight < 0)
// In this case, it's a protocol violation.
throw new ProtocolException("Peer reports invalid best height: " + vPeerVersionMessage.bestHeight);

View file

@ -49,6 +49,8 @@ public class VersionMessage extends Message {
public static final int NODE_NETWORK = 1 << 0;
/** A service bit that denotes whether the peer supports the getutxos message or not. */
public static final int NODE_GETUTXOS = 1 << 1;
/** A service bit used by Bitcoin-ABC to announce Bitcoin Cash nodes. */
public static final int NODE_BITCOIN_CASH = 1 << 5;
/**
* The version number of the protocol spoken.