mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Replace transaction.setComplete() by database.commitTransaction()
This commit is contained in:
@@ -52,11 +52,17 @@ public interface DatabaseComponent {
|
||||
Transaction startTransaction(boolean readOnly) throws DbException;
|
||||
|
||||
/**
|
||||
* Ends a transaction. If the transaction is marked as complete, the
|
||||
* transaction is committed and any events attached to the transaction are
|
||||
* broadcast; otherwise the transaction is aborted.
|
||||
* Commits a transaction to the database.
|
||||
*/
|
||||
void endTransaction(Transaction txn) throws DbException;
|
||||
void commitTransaction(Transaction txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Ends a transaction. If the transaction has not been committed,
|
||||
* it will be aborted. If the transaction has been committed,
|
||||
* any events attached to the transaction are broadcast.
|
||||
* The database lock will be released in either case.
|
||||
*/
|
||||
void endTransaction(Transaction txn);
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Transaction {
|
||||
private final boolean readOnly;
|
||||
|
||||
private List<Event> events = null;
|
||||
private boolean complete = false;
|
||||
private boolean committed = false;
|
||||
|
||||
public Transaction(Object txn, boolean readOnly) {
|
||||
this.txn = txn;
|
||||
@@ -55,18 +55,18 @@ public class Transaction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transaction is ready to be committed.
|
||||
* Returns true if the transaction has been committed.
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return complete;
|
||||
public boolean isCommitted() {
|
||||
return committed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the transaction as ready to be committed. This method must not be
|
||||
* called more than once.
|
||||
* Marks the transaction as committed. This method should only be called
|
||||
* by the DatabaseComponent. It must not be called more than once.
|
||||
*/
|
||||
public void setComplete() {
|
||||
if (complete) throw new IllegalStateException();
|
||||
complete = true;
|
||||
public void setCommitted() {
|
||||
if (committed) throw new IllegalStateException();
|
||||
committed = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user