mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-26 05:26:45 +00:00
move version class to drongo
This commit is contained in:
parent
46034b8f11
commit
da427610d6
5 changed files with 4 additions and 56 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit d5393bd436636bccfcb846192370fbfef4f2a194
|
Subproject commit a26ba49bc6d2431bf72eba6e77c314ed9345d80e
|
|
@ -5,6 +5,7 @@ import com.google.common.net.HostAndPort;
|
||||||
import com.sparrowwallet.drongo.KeyPurpose;
|
import com.sparrowwallet.drongo.KeyPurpose;
|
||||||
import com.sparrowwallet.drongo.Network;
|
import com.sparrowwallet.drongo.Network;
|
||||||
import com.sparrowwallet.drongo.Utils;
|
import com.sparrowwallet.drongo.Utils;
|
||||||
|
import com.sparrowwallet.drongo.Version;
|
||||||
import com.sparrowwallet.drongo.address.Address;
|
import com.sparrowwallet.drongo.address.Address;
|
||||||
import com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException;
|
import com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException;
|
||||||
import com.sparrowwallet.drongo.bip47.PaymentCode;
|
import com.sparrowwallet.drongo.bip47.PaymentCode;
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.sparrowwallet.sparrow.net;
|
|
||||||
|
|
||||||
public class Version implements Comparable<Version> {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.sparrowwallet.sparrow.net;
|
package com.sparrowwallet.sparrow.net;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.Version;
|
||||||
import com.sparrowwallet.drongo.address.Address;
|
import com.sparrowwallet.drongo.address.Address;
|
||||||
import com.sparrowwallet.drongo.address.InvalidAddressException;
|
import com.sparrowwallet.drongo.address.InvalidAddressException;
|
||||||
import com.sparrowwallet.drongo.crypto.ECKey;
|
import com.sparrowwallet.drongo.crypto.ECKey;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.sparrowwallet.drongo.protocol.Sha256Hash;
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.SparrowWallet;
|
import com.sparrowwallet.sparrow.SparrowWallet;
|
||||||
import com.sparrowwallet.sparrow.event.MempoolEntriesInitializedEvent;
|
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.Cormorant;
|
||||||
import com.sparrowwallet.sparrow.net.cormorant.bitcoind.*;
|
import com.sparrowwallet.sparrow.net.cormorant.bitcoind.*;
|
||||||
import com.sparrowwallet.sparrow.net.cormorant.index.TxEntry;
|
import com.sparrowwallet.sparrow.net.cormorant.index.TxEntry;
|
||||||
|
|
Loading…
Reference in a new issue