BATCH_ID and MESSAGE_ID don't need to be structs.

This commit is contained in:
akwizgran
2011-12-07 00:38:14 +00:00
parent b7c3224618
commit 495baf8c70
11 changed files with 65 additions and 95 deletions

View File

@@ -41,7 +41,7 @@ class ProtocolWriterImpl implements ProtocolWriter {
int overhead = serial.getSerialisedStructIdLength(Types.ACK)
+ serial.getSerialisedListStartLength()
+ serial.getSerialisedListEndLength();
int idLength = serial.getSerialisedUniqueIdLength(Types.BATCH_ID);
int idLength = serial.getSerialisedUniqueIdLength();
return (packet - overhead) / idLength;
}
@@ -50,7 +50,7 @@ class ProtocolWriterImpl implements ProtocolWriter {
int overhead = serial.getSerialisedStructIdLength(Types.OFFER)
+ serial.getSerialisedListStartLength()
+ serial.getSerialisedListEndLength();
int idLength = serial.getSerialisedUniqueIdLength(Types.MESSAGE_ID);
int idLength = serial.getSerialisedUniqueIdLength();
return (packet - overhead) / idLength;
}
@@ -65,10 +65,7 @@ class ProtocolWriterImpl implements ProtocolWriter {
public void writeAck(Ack a) throws IOException {
w.writeStructId(Types.ACK);
w.writeListStart();
for(BatchId b : a.getBatchIds()) {
w.writeStructId(Types.BATCH_ID);
w.writeBytes(b.getBytes());
}
for(BatchId b : a.getBatchIds()) w.writeBytes(b.getBytes());
w.writeListEnd();
}
@@ -82,10 +79,7 @@ class ProtocolWriterImpl implements ProtocolWriter {
public void writeOffer(Offer o) throws IOException {
w.writeStructId(Types.OFFER);
w.writeListStart();
for(MessageId m : o.getMessageIds()) {
w.writeStructId(Types.MESSAGE_ID);
w.writeBytes(m.getBytes());
}
for(MessageId m : o.getMessageIds()) w.writeBytes(m.getBytes());
w.writeListEnd();
}