Removing IV of received objects from requested objects list (I forgot that one)
This commit is contained in:
parent
2c4d95af2f
commit
7f4c67f43e
@ -32,10 +32,7 @@ import ch.dissem.bitmessage.utils.UnixTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static ch.dissem.bitmessage.entity.Plaintext.Status.*;
|
||||
import static ch.dissem.bitmessage.entity.Plaintext.Type.BROADCAST;
|
||||
@ -43,8 +40,7 @@ import static ch.dissem.bitmessage.entity.Plaintext.Type.MSG;
|
||||
import static ch.dissem.bitmessage.utils.UnixTime.DAY;
|
||||
|
||||
/**
|
||||
* Use this class if you want to create a Bitmessage client.
|
||||
* <p>
|
||||
* <p>Use this class if you want to create a Bitmessage client.</p>
|
||||
* You'll need the Builder to create a BitmessageContext, and set the following properties:
|
||||
* <ul>
|
||||
* <li>addressRepo</li>
|
||||
@ -54,9 +50,8 @@ import static ch.dissem.bitmessage.utils.UnixTime.DAY;
|
||||
* <li>messageRepo</li>
|
||||
* <li>streams</li>
|
||||
* </ul>
|
||||
* The default implementations in the different module builds can be used.
|
||||
* <p>
|
||||
* The port defaults to 8444 (the default Bitmessage port)
|
||||
* <p>The default implementations in the different module builds can be used.</p>
|
||||
* <p>The port defaults to 8444 (the default Bitmessage port)</p>
|
||||
*/
|
||||
public class BitmessageContext {
|
||||
public static final int CURRENT_VERSION = 3;
|
||||
@ -167,7 +162,6 @@ public class BitmessageContext {
|
||||
}
|
||||
|
||||
private void send(long stream, ObjectPayload payload, long timeToLive) {
|
||||
try {
|
||||
long expires = UnixTime.now(+timeToLive);
|
||||
LOG.info("Expires at " + expires);
|
||||
ObjectMessage object = new ObjectMessage.Builder()
|
||||
@ -179,9 +173,6 @@ public class BitmessageContext {
|
||||
ctx.getNetworkNonceTrialsPerByte(), ctx.getNetworkExtraBytes());
|
||||
ctx.getInventory().storeObject(object);
|
||||
ctx.getNetworkHandler().offer(object.getInventoryVector());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void startup(Listener listener) {
|
||||
|
@ -199,7 +199,6 @@ public class InternalContext {
|
||||
}
|
||||
|
||||
public void requestPubkey(BitmessageAddress contact) {
|
||||
try {
|
||||
long expires = UnixTime.now(+2 * DAY);
|
||||
LOG.info("Expires at " + expires);
|
||||
ObjectMessage response = new ObjectMessage.Builder()
|
||||
@ -210,9 +209,6 @@ public class InternalContext {
|
||||
Security.doProofOfWork(response, proofOfWorkEngine, networkNonceTrialsPerByte, networkExtraBytes);
|
||||
inventory.storeObject(response);
|
||||
networkHandler.offer(response.getInventoryVector());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public long getClientNonce() {
|
||||
|
@ -88,7 +88,7 @@ public class ObjectMessage implements MessagePayload {
|
||||
return stream;
|
||||
}
|
||||
|
||||
public InventoryVector getInventoryVector() throws IOException {
|
||||
public InventoryVector getInventoryVector() {
|
||||
return new InventoryVector(Bytes.truncate(Security.doubleSha512(nonce, getPayloadBytesWithoutNonce()), 32));
|
||||
}
|
||||
|
||||
@ -163,7 +163,8 @@ public class ObjectMessage implements MessagePayload {
|
||||
Encode.varInt(stream, out);
|
||||
}
|
||||
|
||||
public byte[] getPayloadBytesWithoutNonce() throws IOException {
|
||||
public byte[] getPayloadBytesWithoutNonce() {
|
||||
try {
|
||||
if (payloadBytes == null) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
writeHeaderWithoutNonce(out);
|
||||
@ -171,6 +172,9 @@ public class ObjectMessage implements MessagePayload {
|
||||
payloadBytes = out.toByteArray();
|
||||
}
|
||||
return payloadBytes;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
|
@ -287,6 +287,8 @@ public class Connection implements Runnable {
|
||||
} catch (IOException e) {
|
||||
LOG.error("Stream " + objectMessage.getStream() + ", object type " + objectMessage.getType() + ": " + e.getMessage(), e);
|
||||
DebugUtils.saveToFile(objectMessage);
|
||||
} finally {
|
||||
requestedObjects.remove(objectMessage.getInventoryVector());
|
||||
}
|
||||
break;
|
||||
case ADDR:
|
||||
|
Loading…
Reference in New Issue
Block a user