From 1dd49601094a0516899b3cade3eef2f95d5899f4 Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Wed, 8 Nov 2017 14:23:30 +0000 Subject: [PATCH] Transactions that delete old updates must be read-write. --- .../api/properties/TransportPropertyManager.java | 2 +- .../properties/TransportPropertyManagerImpl.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/properties/TransportPropertyManager.java b/bramble-api/src/main/java/org/briarproject/bramble/api/properties/TransportPropertyManager.java index a29698873c..8a219c0c69 100644 --- a/bramble-api/src/main/java/org/briarproject/bramble/api/properties/TransportPropertyManager.java +++ b/bramble-api/src/main/java/org/briarproject/bramble/api/properties/TransportPropertyManager.java @@ -33,7 +33,7 @@ public interface TransportPropertyManager { /** * Returns the local transport properties for all transports. * <br/> - * Read-Only + * TODO: Transaction can be read-only when code is simplified */ Map<TransportId, TransportProperties> getLocalProperties(Transaction txn) throws DbException; diff --git a/bramble-core/src/main/java/org/briarproject/bramble/properties/TransportPropertyManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/properties/TransportPropertyManagerImpl.java index cdd4d57abd..0aa1c7e9f8 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/properties/TransportPropertyManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/properties/TransportPropertyManagerImpl.java @@ -129,7 +129,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager, public Map<TransportId, TransportProperties> getLocalProperties() throws DbException { Map<TransportId, TransportProperties> local; - Transaction txn = db.startTransaction(true); + // TODO: Transaction can be read-only when code is simplified + Transaction txn = db.startTransaction(false); try { local = getLocalProperties(txn); db.commitTransaction(txn); @@ -165,7 +166,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager, throws DbException { try { TransportProperties p = null; - Transaction txn = db.startTransaction(true); + // TODO: Transaction can be read-only when code is simplified + Transaction txn = db.startTransaction(false); try { // Find the latest local update LatestUpdate latest = findLatest(txn, localGroup.getId(), t, @@ -192,7 +194,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager, TransportId t) throws DbException { Map<ContactId, TransportProperties> remote = new HashMap<ContactId, TransportProperties>(); - Transaction txn = db.startTransaction(true); + // TODO: Transaction can be read-only when code is simplified + Transaction txn = db.startTransaction(false); try { for (Contact c : db.getContacts(txn)) remote.put(c.getId(), getRemoteProperties(txn, c, t)); @@ -226,7 +229,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager, public TransportProperties getRemoteProperties(ContactId c, TransportId t) throws DbException { TransportProperties p; - Transaction txn = db.startTransaction(true); + // TODO: Transaction can be read-only when code is simplified + Transaction txn = db.startTransaction(false); try { p = getRemoteProperties(txn, db.getContact(txn, c), t); db.commitTransaction(txn); -- GitLab