mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Renamed a load of things from 'connection' to 'stream'.
This commit is contained in:
@@ -542,14 +542,14 @@ interface Database<T> {
|
||||
Collection<ContactId> getVisibility(T txn, GroupId g) throws DbException;
|
||||
|
||||
/**
|
||||
* Increments the outgoing connection counter for the given endpoint
|
||||
* in the given rotation period and returns the old value, or -1 if the
|
||||
* counter does not exist.
|
||||
* Increments the outgoing stream counter for the given endpoint in the
|
||||
* given rotation period and returns the old value, or -1 if the counter
|
||||
* does not exist.
|
||||
* <p>
|
||||
* Locking: write.
|
||||
*/
|
||||
long incrementConnectionCounter(T txn, ContactId c, TransportId t,
|
||||
long period) throws DbException;
|
||||
long incrementStreamCounter(T txn, ContactId c, TransportId t, long period)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Increments the retention time versions for all contacts to indicate that
|
||||
@@ -694,12 +694,12 @@ interface Database<T> {
|
||||
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the connection reordering window for the given endpoint in the
|
||||
* given rotation period.
|
||||
* Sets the reordering window for the given endpoint in the given rotation
|
||||
* period.
|
||||
* <p>
|
||||
* Locking: write.
|
||||
*/
|
||||
void setConnectionWindow(T txn, ContactId c, TransportId t, long period,
|
||||
void setReorderingWindow(T txn, ContactId c, TransportId t, long period,
|
||||
long centre, byte[] bitmap) throws DbException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -986,7 +986,7 @@ DatabaseCleaner.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public long incrementConnectionCounter(ContactId c, TransportId t,
|
||||
public long incrementStreamCounter(ContactId c, TransportId t,
|
||||
long period) throws DbException {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
@@ -996,7 +996,7 @@ DatabaseCleaner.Callback {
|
||||
throw new NoSuchContactException();
|
||||
if(!db.containsTransport(txn, t))
|
||||
throw new NoSuchTransportException();
|
||||
long counter = db.incrementConnectionCounter(txn, c, t, period);
|
||||
long counter = db.incrementStreamCounter(txn, c, t, period);
|
||||
db.commitTransaction(txn);
|
||||
return counter;
|
||||
} catch(DbException e) {
|
||||
@@ -1401,7 +1401,7 @@ DatabaseCleaner.Callback {
|
||||
eventBus.broadcast(new TransportRemovedEvent(t));
|
||||
}
|
||||
|
||||
public void setConnectionWindow(ContactId c, TransportId t, long period,
|
||||
public void setReorderingWindow(ContactId c, TransportId t, long period,
|
||||
long centre, byte[] bitmap) throws DbException {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
@@ -1411,7 +1411,7 @@ DatabaseCleaner.Callback {
|
||||
throw new NoSuchContactException();
|
||||
if(!db.containsTransport(txn, t))
|
||||
throw new NoSuchTransportException();
|
||||
db.setConnectionWindow(txn, c, t, period, centre, bitmap);
|
||||
db.setReorderingWindow(txn, c, t, period, centre, bitmap);
|
||||
db.commitTransaction(txn);
|
||||
} catch(DbException e) {
|
||||
db.abortTransaction(txn);
|
||||
|
||||
@@ -813,7 +813,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ps.setString(2, s.getTransportId().getString());
|
||||
ps.setLong(3, s.getPeriod());
|
||||
ps.setBytes(4, s.getSecret());
|
||||
ps.setLong(5, s.getOutgoingConnectionCounter());
|
||||
ps.setLong(5, s.getOutgoingStreamCounter());
|
||||
ps.setLong(6, s.getWindowCentre());
|
||||
ps.setBytes(7, s.getWindowBitmap());
|
||||
ps.addBatch();
|
||||
@@ -2433,12 +2433,12 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public long incrementConnectionCounter(Connection txn, ContactId c,
|
||||
public long incrementStreamCounter(Connection txn, ContactId c,
|
||||
TransportId t, long period) throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
// Get the current connection counter
|
||||
// Get the current stream counter
|
||||
String sql = "SELECT outgoing FROM secrets"
|
||||
+ " WHERE contactId = ? AND transportId = ? AND period = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
@@ -2451,11 +2451,11 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ps.close();
|
||||
return -1;
|
||||
}
|
||||
long connection = rs.getLong(1);
|
||||
long streamNumber = rs.getLong(1);
|
||||
if(rs.next()) throw new DbStateException();
|
||||
rs.close();
|
||||
ps.close();
|
||||
// Increment the connection counter
|
||||
// Increment the stream counter
|
||||
sql = "UPDATE secrets SET outgoing = outgoing + 1"
|
||||
+ " WHERE contactId = ? AND transportId = ? AND period = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
@@ -2465,7 +2465,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
int affected = ps.executeUpdate();
|
||||
if(affected != 1) throw new DbStateException();
|
||||
ps.close();
|
||||
return connection;
|
||||
return streamNumber;
|
||||
} catch(SQLException e) {
|
||||
tryToClose(ps);
|
||||
tryToClose(rs);
|
||||
@@ -2907,7 +2907,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
public void setConnectionWindow(Connection txn, ContactId c, TransportId t,
|
||||
public void setReorderingWindow(Connection txn, ContactId c, TransportId t,
|
||||
long period, long centre, byte[] bitmap) throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user