mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Retrieve messages from the database in raw form to avoid creating unnecessary short-lived objects. Added timestamps to headers.
This commit is contained in:
@@ -25,6 +25,8 @@ import net.sf.briar.api.protocol.GroupId;
|
||||
import net.sf.briar.api.protocol.Header;
|
||||
import net.sf.briar.api.protocol.Message;
|
||||
import net.sf.briar.api.protocol.MessageId;
|
||||
import net.sf.briar.api.serial.Raw;
|
||||
import net.sf.briar.api.serial.RawByteArray;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@@ -212,8 +214,8 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
synchronized(messageStatusLock) {
|
||||
Txn txn = db.startTransaction();
|
||||
try {
|
||||
long capacity = Math.min(b.getRemainingCapacity(),
|
||||
Batch.MAX_SIZE);
|
||||
long capacity =
|
||||
Math.min(b.getRemainingCapacity(), Batch.MAX_SIZE);
|
||||
Iterator<MessageId> it =
|
||||
db.getSendableMessages(txn, c, capacity).iterator();
|
||||
if(!it.hasNext()) {
|
||||
@@ -221,13 +223,13 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
return false; // No more messages to send
|
||||
}
|
||||
Set<MessageId> sent = new HashSet<MessageId>();
|
||||
List<Message> messages = new ArrayList<Message>();
|
||||
List<Raw> messages = new ArrayList<Raw>();
|
||||
int bytesSent = 0;
|
||||
while(it.hasNext()) {
|
||||
MessageId m = it.next();
|
||||
Message message = db.getMessage(txn, m);
|
||||
bytesSent += message.getSize();
|
||||
messages.add(message);
|
||||
byte[] message = db.getMessage(txn, m);
|
||||
bytesSent += message.length;
|
||||
messages.add(new RawByteArray(message));
|
||||
sent.add(m);
|
||||
}
|
||||
BatchId batchId = b.addBatch(messages);
|
||||
|
||||
Reference in New Issue
Block a user