mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Calculate the timestamp outside the subscription/transport update
writer - this will allow it to be saved so new connections can work out whether they should send updates.
This commit is contained in:
@@ -445,7 +445,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
Txn txn = db.startTransaction();
|
||||
try {
|
||||
Map<Group, Long> subs = db.getVisibleSubscriptions(txn, c);
|
||||
s.writeSubscriptions(subs);
|
||||
s.writeSubscriptionUpdate(subs, System.currentTimeMillis());
|
||||
if(LOG.isLoggable(Level.FINE))
|
||||
LOG.fine("Added " + subs.size() + " subscriptions");
|
||||
db.commitTransaction(txn);
|
||||
@@ -475,7 +475,8 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
try {
|
||||
Map<String, Map<String, String>> transports =
|
||||
db.getTransports(txn);
|
||||
t.writeTransports(transports);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
t.writeTransportUpdate(transports, timestamp);
|
||||
if(LOG.isLoggable(Level.FINE))
|
||||
LOG.fine("Added " + transports.size() + " transports");
|
||||
db.commitTransaction(txn);
|
||||
|
||||
@@ -339,7 +339,7 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
Txn txn = db.startTransaction();
|
||||
try {
|
||||
Map<Group, Long> subs = db.getVisibleSubscriptions(txn, c);
|
||||
s.writeSubscriptions(subs);
|
||||
s.writeSubscriptionUpdate(subs, System.currentTimeMillis());
|
||||
if(LOG.isLoggable(Level.FINE))
|
||||
LOG.fine("Added " + subs.size() + " subscriptions");
|
||||
db.commitTransaction(txn);
|
||||
@@ -363,7 +363,8 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
try {
|
||||
Map<String, Map<String, String>> transports =
|
||||
db.getTransports(txn);
|
||||
t.writeTransports(transports);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
t.writeTransportUpdate(transports, timestamp);
|
||||
if(LOG.isLoggable(Level.FINE))
|
||||
LOG.fine("Added " + transports.size() + " transports");
|
||||
db.commitTransaction(txn);
|
||||
|
||||
@@ -20,10 +20,11 @@ class SubscriptionWriterImpl implements SubscriptionWriter {
|
||||
w = writerFactory.createWriter(out);
|
||||
}
|
||||
|
||||
public void writeSubscriptions(Map<Group, Long> subs) throws IOException {
|
||||
public void writeSubscriptionUpdate(Map<Group, Long> subs, long timestamp)
|
||||
throws IOException {
|
||||
w.writeUserDefinedTag(Tags.SUBSCRIPTION_UPDATE);
|
||||
w.writeMap(subs);
|
||||
w.writeInt64(System.currentTimeMillis());
|
||||
w.writeInt64(timestamp);
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ class TransportWriterImpl implements TransportWriter {
|
||||
w = writerFactory.createWriter(out);
|
||||
}
|
||||
|
||||
public void writeTransports(Map<String, Map<String, String>> transports)
|
||||
public void writeTransportUpdate(
|
||||
Map<String, Map<String, String>> transports, long timestamp)
|
||||
throws IOException {
|
||||
w.writeUserDefinedTag(Tags.TRANSPORT_UPDATE);
|
||||
w.writeListStart();
|
||||
@@ -30,7 +31,7 @@ class TransportWriterImpl implements TransportWriter {
|
||||
w.writeMap(e.getValue());
|
||||
}
|
||||
w.writeListEnd();
|
||||
w.writeInt64(System.currentTimeMillis());
|
||||
w.writeInt64(timestamp);
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user