VersionMessage: deprecate isPingPongSupported() and ProtocolVersion.PONG

Our minimum version is at 70000 already.
This commit is contained in:
Andreas Schildbach 2023-03-30 19:33:46 +02:00
parent fccb164c90
commit 6133dccc21
4 changed files with 4 additions and 9 deletions

View File

@ -554,6 +554,7 @@ public abstract class NetworkParameters {
public static enum ProtocolVersion { public static enum ProtocolVersion {
MINIMUM(70000), MINIMUM(70000),
@Deprecated
PONG(60001), PONG(60001),
BLOOM_FILTER(70001), // BIP37 BLOOM_FILTER(70001), // BIP37
BLOOM_FILTER_BIP111(70011), // BIP111 BLOOM_FILTER_BIP111(70011), // BIP111

View File

@ -1545,8 +1545,6 @@ public class Peer extends PeerSocketHandler {
protected CompletableFuture<Duration> sendPing(long nonce) { protected CompletableFuture<Duration> sendPing(long nonce) {
final VersionMessage ver = vPeerVersionMessage; final VersionMessage ver = vPeerVersionMessage;
if (!ver.isPingPongSupported())
return FutureUtils.failedFuture(new ProtocolException("Peer version is too low for measurable pings: " + ver));
if (pendingPings.size() > PENDING_PINGS_LIMIT) { if (pendingPings.size() > PENDING_PINGS_LIMIT) {
log.info("{}: Too many pending pings, disconnecting", this); log.info("{}: Too many pending pings, disconnecting", this);
close(); close();

View File

@ -1691,8 +1691,6 @@ public class PeerGroup implements TransactionBroadcaster {
return; // Disabled. return; // Disabled.
} }
for (Peer peer : getConnectedPeers()) { for (Peer peer : getConnectedPeers()) {
if (peer.getPeerVersionMessage().clientVersion < params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.PONG))
continue;
peer.sendPing(); peer.sendPing();
} }
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -243,12 +243,10 @@ public class VersionMessage extends Message {
throw new IllegalArgumentException("name contains invalid characters"); throw new IllegalArgumentException("name contains invalid characters");
} }
/** /** @deprecated just assume {@link Ping} and {@link Pong} are supported */
* Returns true if the clientVersion field is {@link NetworkParameters.ProtocolVersion#PONG} or higher. @Deprecated
* If it is then {@link Peer#sendPing()} is usable.
*/
public boolean isPingPongSupported() { public boolean isPingPongSupported() {
return clientVersion >= params.getProtocolVersionNum(NetworkParameters.ProtocolVersion.PONG); return true;
} }
/** /**