mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 22:59:54 +01:00
Increased the maximum packet size to 1 MiB.
This should provide acceptable memory usage and database locking granularity, while making subscription and transport updates large enough for the incremental update issue to be kicked into the long grass. Removed awareness of the serialisation format from the protocol component wherever possible, and added tests to ensure that the constants defined in the protocol package's API are compatible with the serialisation format.
This commit is contained in:
@@ -3,8 +3,8 @@ package net.sf.briar.protocol.writers;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.sf.briar.api.protocol.Ack;
|
||||
import net.sf.briar.api.protocol.BatchId;
|
||||
import net.sf.briar.api.protocol.ProtocolConstants;
|
||||
import net.sf.briar.api.protocol.Tags;
|
||||
import net.sf.briar.api.protocol.writers.AckWriter;
|
||||
import net.sf.briar.api.serial.Writer;
|
||||
@@ -16,6 +16,7 @@ class AckWriterImpl implements AckWriter {
|
||||
private final Writer w;
|
||||
|
||||
private boolean started = false;
|
||||
private int idsWritten = 0;
|
||||
|
||||
AckWriterImpl(OutputStream out, WriterFactory writerFactory) {
|
||||
this.out = out;
|
||||
@@ -28,12 +29,9 @@ class AckWriterImpl implements AckWriter {
|
||||
w.writeListStart();
|
||||
started = true;
|
||||
}
|
||||
int capacity = ProtocolConstants.MAX_PACKET_LENGTH
|
||||
- (int) w.getBytesWritten() - 1;
|
||||
// Allow one byte for the BATCH_ID tag, one byte for the BYTES tag and
|
||||
// one byte for the length as a uint7
|
||||
if(capacity < BatchId.LENGTH + 3) return false;
|
||||
if(idsWritten >= Ack.MAX_IDS_PER_ACK) return false;
|
||||
b.writeTo(w);
|
||||
idsWritten++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class BatchWriterImpl implements BatchWriter {
|
||||
w.writeListStart();
|
||||
started = true;
|
||||
}
|
||||
// Allow one byte for the list end tag
|
||||
int capacity = ProtocolConstants.MAX_PACKET_LENGTH
|
||||
- (int) w.getBytesWritten() - 1;
|
||||
if(capacity < message.length) return false;
|
||||
|
||||
@@ -6,8 +6,8 @@ import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import net.sf.briar.api.protocol.MessageId;
|
||||
import net.sf.briar.api.protocol.Offer;
|
||||
import net.sf.briar.api.protocol.OfferId;
|
||||
import net.sf.briar.api.protocol.ProtocolConstants;
|
||||
import net.sf.briar.api.protocol.Tags;
|
||||
import net.sf.briar.api.protocol.writers.OfferWriter;
|
||||
import net.sf.briar.api.serial.Writer;
|
||||
@@ -20,6 +20,7 @@ class OfferWriterImpl implements OfferWriter {
|
||||
private final MessageDigest messageDigest;
|
||||
|
||||
private boolean started = false;
|
||||
private int idsWritten = 0;
|
||||
|
||||
OfferWriterImpl(OutputStream out, WriterFactory writerFactory,
|
||||
MessageDigest messageDigest) {
|
||||
@@ -35,12 +36,9 @@ class OfferWriterImpl implements OfferWriter {
|
||||
w.writeListStart();
|
||||
started = true;
|
||||
}
|
||||
int capacity = ProtocolConstants.MAX_PACKET_LENGTH
|
||||
- (int) w.getBytesWritten() - 1;
|
||||
// Allow one byte for the MESSAGE_ID tag, one byte for the BYTES tag
|
||||
// and one byte for the length as a uint7
|
||||
if(capacity < MessageId.LENGTH + 3) return false;
|
||||
if(idsWritten >= Offer.MAX_IDS_PER_OFFER) return false;
|
||||
m.writeTo(w);
|
||||
idsWritten++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user