Associate a timestamp with every subscription, indicating the earliest

acceptable timestamp of subscribed messages. For a new subscription,
the timestamp is initialised to the current time, so a new subscriber
to a group will not immediately receive any messages. (Subscribing to
a group is therefore more like joining a mailing list than joining a
Usenet group - you only receive messages written after you joined.)

Once the database fills up and starts expiring messages, the
timestamps of subscriptions are updated so that contacts need not send
messages that would expire immediately. This is done using the
*approximate* timestamp of the oldest message in the database, to
avoid revealing the presence or absence of any particular message.
This commit is contained in:
akwizgran
2011-08-05 13:34:58 +01:00
parent 6c5ce05c5d
commit c2045296eb
15 changed files with 283 additions and 130 deletions

View File

@@ -2,7 +2,7 @@ package net.sf.briar.protocol.writers;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Map;
import net.sf.briar.api.protocol.Group;
import net.sf.briar.api.protocol.Tags;
@@ -20,9 +20,9 @@ class SubscriptionWriterImpl implements SubscriptionWriter {
w = writerFactory.createWriter(out);
}
public void writeSubscriptions(Collection<Group> subs) throws IOException {
public void writeSubscriptions(Map<Group, Long> subs) throws IOException {
w.writeUserDefinedTag(Tags.SUBSCRIPTIONS);
w.writeList(subs);
w.writeMap(subs);
w.writeInt64(System.currentTimeMillis());
out.flush();
}