Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
Merge pull request #34 from ManfredKarrer/merged-voting
Browse files Browse the repository at this point in the history
Add DAO code
  • Loading branch information
ManfredKarrer committed Aug 15, 2018
2 parents c02e2ad + 88bb79c commit 2881cfe
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 225 deletions.
7 changes: 4 additions & 3 deletions src/main/java/bisq/common/app/Version.java
Expand Up @@ -118,8 +118,9 @@ public static void printVersion() {
'}');
}

public static final byte COMPENSATION_REQUEST_VERSION = (byte) 0x01;
public static final byte COMPENSATION_REQUEST = (byte) 0x01;
public static final byte PROPOSAL = (byte) 0x01;
public static final byte BLIND_VOTE_VERSION = (byte) 0x01;
public static final byte VOTE_REVEAL_VERSION = (byte) 0x01;
public static final byte BLIND_VOTE = (byte) 0x01;
public static final byte VOTE_REVEAL = (byte) 0x01;
public static final byte LOCKUP = (byte) 0x01;
}
4 changes: 2 additions & 2 deletions src/main/java/bisq/common/proto/ProtoUtil.java
Expand Up @@ -64,11 +64,11 @@ public static byte[] byteArrayOrNullFromProto(ByteString proto) {
* @param <E> the enum Type
* @return an enum
*/
@Nullable
public static <E extends Enum<E>> E enumFromProto(Class<E> enumType, String name) {
E result = Enums.getIfPresent(enumType, name).orNull();
if (result == null) {
if (result == null)
log.error("Invalid value for enum " + enumType.getSimpleName() + ": " + name);
}

return result;
}
Expand Down
Expand Up @@ -25,10 +25,12 @@
import java.util.function.Function;
import java.util.stream.Stream;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Delegate;

@EqualsAndHashCode
public class PersistableList<T extends PersistablePayload> implements PersistableEnvelope, Iterable<T> {
@Delegate(excludes = ExcludesDelegateMethods.class)
@Getter
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/bisq/common/storage/Storage.java
Expand Up @@ -17,6 +17,7 @@

package bisq.common.storage;

import bisq.common.app.DevEnv;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistenceProtoResolver;

Expand Down Expand Up @@ -165,6 +166,7 @@ private T getPersisted() {
try {
// We keep a backup which might be used for recovery
fileManager.removeAndBackupFile(fileName);
DevEnv.logErrorAndThrowIfDevMode(t.toString());
} catch (IOException e1) {
e1.printStackTrace();
log.error(e1.getMessage());
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/bisq/common/util/Utilities.java
Expand Up @@ -601,4 +601,21 @@ public static boolean isRestrictedCryptography() {
return name != null && name.equals("Java(TM) SE Runtime Environment")
&& ver != null && (ver.startsWith("1.7") || ver.startsWith("1.8"));
}

public static byte[] integerToByteArray(int intValue, int numBytes) {
byte[] bytes = new byte[numBytes];
for (int i = numBytes - 1; i >= 0; i--) {
bytes[i] = ((byte) (intValue & 0xFF));
intValue >>>= 8;
}
return bytes;
}

public static int byteArrayToInteger(byte[] bytes) {
int result = 0;
for (byte aByte : bytes) {
result = result << 8 | aByte & 0xff;
}
return result;
}
}

0 comments on commit 2881cfe

Please sign in to comment.