diff --git a/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Message.java b/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Message.java index 33e7b81..98c84bd 100644 --- a/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Message.java +++ b/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Message.java @@ -84,7 +84,7 @@ public class Message implements ExtendedEncoding.ExtendedType { } packer.packMapHeader(size); packer.packString(""); - packer.packString("message"); + packer.packString(TYPE); packer.packString("subject"); packer.packString(subject); packer.packString("body"); diff --git a/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Vote.java b/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Vote.java index 75cea67..d0beddd 100644 --- a/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Vote.java +++ b/core/src/main/java/ch/dissem/bitmessage/entity/valueobject/extended/Vote.java @@ -58,7 +58,7 @@ public class Vote implements ExtendedEncoding.ExtendedType { public void pack(MessagePacker packer) throws IOException { packer.packMapHeader(3); packer.packString(""); - packer.packString("vote"); + packer.packString(TYPE); packer.packString("msgId"); packer.packBinaryHeader(msgId.getHash().length); packer.writePayload(msgId.getHash()); diff --git a/core/src/main/java/ch/dissem/bitmessage/factory/ExtendedEncodingFactory.java b/core/src/main/java/ch/dissem/bitmessage/factory/ExtendedEncodingFactory.java index 0dc419c..29595da 100644 --- a/core/src/main/java/ch/dissem/bitmessage/factory/ExtendedEncodingFactory.java +++ b/core/src/main/java/ch/dissem/bitmessage/factory/ExtendedEncodingFactory.java @@ -22,6 +22,7 @@ import java.util.zip.InflaterInputStream; public class ExtendedEncodingFactory { private static final Logger LOG = LoggerFactory.getLogger(ExtendedEncodingFactory.class); private static final ExtendedEncodingFactory INSTANCE = new ExtendedEncodingFactory(); + private static final String KEY_MESSAGE_TYPE = ""; private Map> factories = new HashMap<>(); private ExtendedEncodingFactory() { @@ -39,7 +40,7 @@ public class ExtendedEncodingFactory { MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(unzipper); int mapSize = unpacker.unpackMapHeader(); String key = unpacker.unpackString(); - if (!"".equals(key)) { + if (!KEY_MESSAGE_TYPE.equals(key)) { LOG.error("Unexpected content: " + key); return null; } diff --git a/core/src/main/java/ch/dissem/bitmessage/utils/Bytes.java b/core/src/main/java/ch/dissem/bitmessage/utils/Bytes.java index c0bf554..986c288 100644 --- a/core/src/main/java/ch/dissem/bitmessage/utils/Bytes.java +++ b/core/src/main/java/ch/dissem/bitmessage/utils/Bytes.java @@ -16,11 +16,6 @@ package ch.dissem.bitmessage.utils; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.file.Files; - /** * A helper class for working with byte arrays interpreted as unsigned big endian integers. * This is one part due to the fact that Java doesn't support unsigned numbers, and another