Merge branch '427-local-author-caching' into 'master'

Cache the local author and load before the db latch is released

Closes #427, #588 

See merge request !354
This commit is contained in:
akwizgran
2016-11-01 17:21:14 +00:00
45 changed files with 294 additions and 665 deletions

View File

@@ -9,8 +9,6 @@ import org.briarproject.api.db.DbException;
import org.briarproject.api.db.Transaction;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.AuthorId;
import org.briarproject.api.identity.IdentityManager.RemoveIdentityHook;
import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.transport.KeyManager;
import java.util.ArrayList;
@@ -21,7 +19,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import javax.inject.Inject;
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
class ContactManagerImpl implements ContactManager {
private final DatabaseComponent db;
private final KeyManager keyManager;
@@ -148,11 +146,4 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
db.removeContact(txn, c);
}
@Override
public void removingIdentity(Transaction txn, LocalAuthor a)
throws DbException {
// Remove any contacts of the local pseudonym that's being removed
for (ContactId c : db.getContacts(txn, a.getId()))
removeContact(txn, c);
}
}

View File

@@ -2,17 +2,6 @@ package org.briarproject.contact;
import org.briarproject.api.contact.ContactExchangeTask;
import org.briarproject.api.contact.ContactManager;
import org.briarproject.api.crypto.CryptoComponent;
import org.briarproject.api.data.BdfReaderFactory;
import org.briarproject.api.data.BdfWriterFactory;
import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.identity.AuthorFactory;
import org.briarproject.api.identity.IdentityManager;
import org.briarproject.api.plugins.ConnectionManager;
import org.briarproject.api.properties.TransportPropertyManager;
import org.briarproject.api.system.Clock;
import org.briarproject.api.transport.StreamReaderFactory;
import org.briarproject.api.transport.StreamWriterFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -30,9 +19,7 @@ public class ContactModule {
@Provides
@Singleton
ContactManager getContactManager(IdentityManager identityManager,
ContactManagerImpl contactManager) {
identityManager.registerRemoveIdentityHook(contactManager);
ContactManager getContactManager(ContactManagerImpl contactManager) {
return contactManager;
}