diff --git a/README.md b/README.md index 0f536d9..75f2b28 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A Java implementation for the Bitmessage protocol. To build, use command `./grad Please note that it still has its limitations, but the API should now be stable. Jabit uses Semantic Versioning, meaning as long as the major version doesn't change, nothing should break if you update. -Be aware though that this doesn't necessarily applies for SNAPSHOT builds and the development branch, notably when it comes to database updates. _In other words, they may break your installation!_ +Be aware though that this doesn't necessarily applies for SNAPSHOT builds and the development branch, notably when it comes to database updates. In other words, they may break your installation!_ #### Master [![Build Status](https://travis-ci.org/Dissem/Jabit.svg?branch=master)](https://travis-ci.org/Dissem/Jabit) diff --git a/core/build.gradle b/core/build.gradle index 2fe6d50..2fb78cd 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -25,7 +25,7 @@ artifacts { dependencies { compile 'org.slf4j:slf4j-api:1.7.12' - compile 'ch.dissem.msgpack:msgpack:development-SNAPSHOT' + compile 'ch.dissem.msgpack:msgpack:1.0.0' testCompile 'junit:junit:4.12' testCompile 'org.hamcrest:hamcrest-library:1.3' testCompile 'org.mockito:mockito-core:1.10.19' diff --git a/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java b/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java index b61f747..bdb61b6 100644 --- a/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java +++ b/core/src/main/java/ch/dissem/bitmessage/DefaultMessageListener.java @@ -87,7 +87,7 @@ class DefaultMessageListener implements NetworkHandler.MessageListener, Internal BitmessageAddress identity = ctx.getAddressRepository().findIdentity(getPubkey.getRipeTag()); if (identity != null && identity.getPrivateKey() != null && !identity.isChan()) { LOG.info("Got pubkey request for identity " + identity); - // FIXME: only send pubkey if it wasn't sent in the last 28 days + // FIXME: only send pubkey if it wasn't sent in the last TTL.pubkey() days ctx.sendPubkey(identity, object.getStream()); } } diff --git a/core/src/main/java/ch/dissem/bitmessage/entity/Plaintext.java b/core/src/main/java/ch/dissem/bitmessage/entity/Plaintext.java index e46fd2a..dad561d 100644 --- a/core/src/main/java/ch/dissem/bitmessage/entity/Plaintext.java +++ b/core/src/main/java/ch/dissem/bitmessage/entity/Plaintext.java @@ -18,22 +18,20 @@ package ch.dissem.bitmessage.entity; import ch.dissem.bitmessage.entity.payload.Msg; import ch.dissem.bitmessage.entity.payload.Pubkey.Feature; -import ch.dissem.bitmessage.entity.valueobject.extended.Attachment; import ch.dissem.bitmessage.entity.valueobject.ExtendedEncoding; import ch.dissem.bitmessage.entity.valueobject.InventoryVector; import ch.dissem.bitmessage.entity.valueobject.Label; +import ch.dissem.bitmessage.entity.valueobject.extended.Attachment; import ch.dissem.bitmessage.entity.valueobject.extended.Message; import ch.dissem.bitmessage.exception.ApplicationException; import ch.dissem.bitmessage.factory.ExtendedEncodingFactory; import ch.dissem.bitmessage.factory.Factory; -import ch.dissem.bitmessage.utils.Decode; -import ch.dissem.bitmessage.utils.Encode; -import ch.dissem.bitmessage.utils.TTL; -import ch.dissem.bitmessage.utils.UnixTime; +import ch.dissem.bitmessage.utils.*; import java.io.*; import java.nio.ByteBuffer; import java.util.*; +import java.util.Collections; import static ch.dissem.bitmessage.entity.Plaintext.Encoding.EXTENDED; import static ch.dissem.bitmessage.entity.Plaintext.Encoding.SIMPLE; @@ -50,6 +48,7 @@ public class Plaintext implements Streamable { private final long encoding; private final byte[] message; private final byte[] ackData; + private final UUID conversationId; private ExtendedEncoding extendedData; private ObjectMessage ackMessage; private Object id; @@ -90,6 +89,7 @@ public class Plaintext implements Streamable { ttl = builder.ttl; retries = builder.retries; nextTry = builder.nextTry; + conversationId = builder.conversation; } public static Plaintext read(Type type, InputStream in) throws IOException { @@ -390,7 +390,7 @@ public class Plaintext implements Streamable { } public List getParents() { - if (Message.TYPE.equals(getExtendedData().getType())) { + if (getExtendedData() != null && Message.TYPE.equals(getExtendedData().getType())) { return ((Message) extendedData.getContent()).getParents(); } else { return Collections.emptyList(); @@ -405,6 +405,10 @@ public class Plaintext implements Streamable { } } + public UUID getConversationId() { + return conversationId; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -470,6 +474,16 @@ public class Plaintext implements Streamable { return initialHash; } + @Override + public String toString() { + String subject = getSubject(); + if (subject == null || subject.length() == 0) { + return Strings.hex(initialHash).toString(); + } else { + return subject; + } + } + public enum Encoding { IGNORE(0), TRIVIAL(1), SIMPLE(2), EXTENDED(3); @@ -527,12 +541,13 @@ public class Plaintext implements Streamable { private byte[] ackMessage; private byte[] signature; private long sent; - private long received; + private Long received; private Status status; private Set