From da427610d6d1edc5e899f34e302d5fdba01ae73a Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 25 Nov 2024 15:53:27 +0200 Subject: [PATCH] move version class to drongo --- drongo | 2 +- .../sparrow/net/ElectrumServer.java | 1 + .../sparrowwallet/sparrow/net/Version.java | 54 ------------------- .../sparrow/net/VersionCheckService.java | 1 + .../electrum/ElectrumServerService.java | 2 +- 5 files changed, 4 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/com/sparrowwallet/sparrow/net/Version.java diff --git a/drongo b/drongo index d5393bd4..a26ba49b 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit d5393bd436636bccfcb846192370fbfef4f2a194 +Subproject commit a26ba49bc6d2431bf72eba6e77c314ed9345d80e diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 32696de1..17c3d60c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -5,6 +5,7 @@ import com.google.common.net.HostAndPort; import com.sparrowwallet.drongo.KeyPurpose; import com.sparrowwallet.drongo.Network; import com.sparrowwallet.drongo.Utils; +import com.sparrowwallet.drongo.Version; import com.sparrowwallet.drongo.address.Address; import com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException; import com.sparrowwallet.drongo.bip47.PaymentCode; diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Version.java b/src/main/java/com/sparrowwallet/sparrow/net/Version.java deleted file mode 100644 index 1310881f..00000000 --- a/src/main/java/com/sparrowwallet/sparrow/net/Version.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.sparrowwallet.sparrow.net; - -public class Version implements Comparable { - private final String version; - - public final String get() { - return this.version; - } - - public Version(String version) { - if(version == null) { - throw new IllegalArgumentException("Version can not be null"); - } - if(!version.matches("[0-9]+(\\.[0-9]+)*")) { - throw new IllegalArgumentException("Invalid version format"); - } - this.version = version; - } - - @Override - public int compareTo(Version that) { - if(that == null) { - return 1; - } - String[] thisParts = this.get().split("\\."); - String[] thatParts = that.get().split("\\."); - int length = Math.max(thisParts.length, thatParts.length); - for(int i = 0; i < length; i++) { - int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0; - int thatPart = i < thatParts.length ? Integer.parseInt(thatParts[i]) : 0; - if(thisPart < thatPart) { - return -1; - } - if(thisPart > thatPart) { - return 1; - } - } - return 0; - } - - @Override - public boolean equals(Object that) { - if(this == that) { - return true; - } - if(that == null) { - return false; - } - if(this.getClass() != that.getClass()) { - return false; - } - return this.compareTo((Version) that) == 0; - } -} diff --git a/src/main/java/com/sparrowwallet/sparrow/net/VersionCheckService.java b/src/main/java/com/sparrowwallet/sparrow/net/VersionCheckService.java index d62e780c..55ee45b0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/VersionCheckService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/VersionCheckService.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.net; +import com.sparrowwallet.drongo.Version; import com.sparrowwallet.drongo.address.Address; import com.sparrowwallet.drongo.address.InvalidAddressException; import com.sparrowwallet.drongo.crypto.ECKey; diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java index d9ed6e16..3eaf3b7a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/electrum/ElectrumServerService.java @@ -9,7 +9,7 @@ import com.sparrowwallet.drongo.protocol.Sha256Hash; import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.SparrowWallet; import com.sparrowwallet.sparrow.event.MempoolEntriesInitializedEvent; -import com.sparrowwallet.sparrow.net.Version; +import com.sparrowwallet.drongo.Version; import com.sparrowwallet.sparrow.net.cormorant.Cormorant; import com.sparrowwallet.sparrow.net.cormorant.bitcoind.*; import com.sparrowwallet.sparrow.net.cormorant.index.TxEntry;