Peer: Disconnect peers without copy of the block chain gracefully.

Previously, a protocol exception was thrown, spamming error reporting facilities with useless messages.
This commit is contained in:
Andreas Schildbach
2016-02-16 16:44:44 +01:00
parent 39f0675866
commit a1def190ad

View File

@@ -537,10 +537,15 @@ 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.
if (!vPeerVersionMessage.hasBlockChain() ||
(!params.allowEmptyPeerChain() && vPeerVersionMessage.bestHeight <= 0)) {
// Shut down the channel
throw new ProtocolException("Peer does not have a copy of the block chain.");
(!params.allowEmptyPeerChain() && vPeerVersionMessage.bestHeight == 0)) {
// Shut down the channel gracefully.
log.info("{}: Peer does not have a copy of the block chain.", this);
close();
return;
}
if (vPeerVersionMessage.bestHeight < 0)
// In this case, it's a protocol violation.
throw new ProtocolException("Peer reports invalid best height: " + vPeerVersionMessage.bestHeight);
versionHandshakeFuture.set(this);
}