Skip to content

Commit

Permalink
Merge pull request #3280 from bisq-network/release/v1.1.6
Browse files Browse the repository at this point in the history
Release/v1.1.6
  • Loading branch information
ripcurlx authored Sep 17, 2019
2 parents 85f9ead + cc3128d commit 37eef84
Show file tree
Hide file tree
Showing 313 changed files with 18,245 additions and 5,497 deletions.
1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ configure(project(':desktop')) {
apply plugin: 'witness'
apply from: '../gradle/witness/gradle-witness.gradle'

version = '1.1.5-SNAPSHOT'
version = '1.1.6-SNAPSHOT'

mainClassName = 'bisq.desktop.app.BisqAppMain'

Expand Down
50 changes: 48 additions & 2 deletions common/src/main/java/bisq/common/app/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

package bisq.common.app;

import com.google.common.base.Joiner;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -43,7 +47,7 @@ public class Capabilities {

// Defines which most recent capability any node need to support.
// This helps to clean network from very old inactive but still running nodes.
private static final Capability mandatoryCapability = Capability.DAO_STATE;
private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE;

protected final Set<Capability> capabilities = new HashSet<>();

Expand Down Expand Up @@ -101,7 +105,7 @@ public boolean isEmpty() {
* @return int list of Capability ordinals
*/
public static List<Integer> toIntList(Capabilities capabilities) {
return capabilities.capabilities.stream().map(capability -> capability.ordinal()).sorted().collect(Collectors.toList());
return capabilities.capabilities.stream().map(Enum::ordinal).sorted().collect(Collectors.toList());
}

/**
Expand All @@ -113,11 +117,46 @@ public static List<Integer> toIntList(Capabilities capabilities) {
public static Capabilities fromIntList(List<Integer> capabilities) {
return new Capabilities(capabilities.stream()
.filter(integer -> integer < Capability.values().length)
.filter(integer -> integer >= 0)
.map(integer -> Capability.values()[integer])
.collect(Collectors.toSet()));
}

/**
*
* @param list Comma separated list of Capability ordinals.
* @return Capabilities
*/
public static Capabilities fromStringList(String list) {
if (list == null || list.isEmpty())
return new Capabilities();

List<String> entries = List.of(list.replace(" ", "").split(","));
List<Integer> capabilitiesList = entries.stream()
.map(c -> {
try {
return Integer.parseInt(c);
} catch (Throwable e) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
return Capabilities.fromIntList(capabilitiesList);
}

/**
* @return Converts capabilities to list of ordinals as comma separated strings
*/
public String toStringList() {
return Joiner.on(", ").join(Capabilities.toIntList(this));
}

public static boolean hasMandatoryCapability(Capabilities capabilities) {
return hasMandatoryCapability(capabilities, MANDATORY_CAPABILITY);
}

public static boolean hasMandatoryCapability(Capabilities capabilities, Capability mandatoryCapability) {
return capabilities.capabilities.stream().anyMatch(c -> c == mandatoryCapability);
}

Expand All @@ -126,6 +165,13 @@ public String toString() {
return Arrays.toString(Capabilities.toIntList(this).toArray());
}

public String prettyPrint() {
return capabilities.stream()
.sorted(Comparator.comparingInt(Enum::ordinal))
.map(e -> e.name() + " [" + e.ordinal() + "]")
.collect(Collectors.joining(", "));
}

public int size() {
return capabilities.size();
}
Expand Down
31 changes: 18 additions & 13 deletions common/src/main/java/bisq/common/app/Capability.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@
// We can define here special features the client is supporting.
// Useful for updates to new versions where a new data type would break backwards compatibility or to
// limit a node to certain behaviour and roles like the seed nodes.
// We don't use the Enum in any serialized data, as changes in the enum would break backwards compatibility. We use the ordinal integer instead.
// We don't use the Enum in any serialized data, as changes in the enum would break backwards compatibility.
// We use the ordinal integer instead.
// Sequence in the enum must not be changed (append only).
public enum Capability {
TRADE_STATISTICS,
TRADE_STATISTICS_2,
ACCOUNT_AGE_WITNESS,
SEED_NODE,
DAO_FULL_NODE,
PROPOSAL,
BLIND_VOTE,
ACK_MSG,
RECEIVE_BSQ_BLOCK,
DAO_STATE,
BUNDLE_OF_ENVELOPES,
SIGNED_ACCOUNT_AGE_WITNESS
@Deprecated TRADE_STATISTICS, // Not required anymore as no old clients out there not having that support
@Deprecated TRADE_STATISTICS_2, // Not required anymore as no old clients out there not having that support
@Deprecated ACCOUNT_AGE_WITNESS, // Not required anymore as no old clients out there not having that support
SEED_NODE, // Node is a seed node
DAO_FULL_NODE, // DAO full node can deliver BSQ blocks
@Deprecated PROPOSAL, // Not required anymore as no old clients out there not having that support
@Deprecated BLIND_VOTE, // Not required anymore as no old clients out there not having that support
@Deprecated ACK_MSG, // Not required anymore as no old clients out there not having that support
RECEIVE_BSQ_BLOCK, // Signaling that node which wants to receive BSQ blocks (DAO lite node)
@Deprecated DAO_STATE, // Not required anymore as no old clients out there not having that support

//TODO can be set deprecated after v1.1.6 as we enforce update there
BUNDLE_OF_ENVELOPES, // Supports bundling of messages if many messages are sent in short interval

SIGNED_ACCOUNT_AGE_WITNESS, // Supports the signed account age witness feature
MEDIATION // Supports mediation feature
}
1 change: 0 additions & 1 deletion common/src/main/java/bisq/common/app/DevEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static void setup(Injector injector) {

// If set to true we ignore several UI behavior like confirmation popups as well dummy accounts are created and
// offers are filled with default values. Intended to make dev testing faster.
@SuppressWarnings("PointlessBooleanExpression")
private static boolean devMode = false;

public static boolean isDevMode() {
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/bisq/common/app/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Version {
// VERSION = 0.5.0 introduces proto buffer for the P2P network and local DB and is a not backward compatible update
// Therefore all sub versions start again with 1
// We use semantic versioning with major, minor and patch
public static final String VERSION = "1.1.5";
public static final String VERSION = "1.1.6";

public static int getMajorVersion(String version) {
return getSubVersion(version, 0);
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/bisq/common/taskrunner/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Task(TaskRunner taskHandler, T model) {
this.model = model;
}

abstract protected void run();
protected abstract void run();

protected void runInterceptHook() {
if (getClass() == taskToIntercept)
Expand Down
15 changes: 15 additions & 0 deletions common/src/main/java/bisq/common/util/MathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,19 @@ public static double scaleDownByPowerOf10(long value, int exponent) {
public static double exactMultiply(double value1, double value2) {
return BigDecimal.valueOf(value1).multiply(BigDecimal.valueOf(value2)).doubleValue();
}

public static long getMedian(Long[] list) {
if (list.length == 0) {
return 0L;
}

int middle = list.length / 2;
long median;
if (list.length % 2 == 1) {
median = list[middle];
} else {
median = MathUtils.roundDoubleToLong((list[middle - 1] + list[middle]) / 2.0);
}
return median;
}
}
Loading

0 comments on commit 37eef84

Please sign in to comment.