Add database methods for static keys.

This commit is contained in:
akwizgran
2019-04-16 17:51:31 +01:00
parent 0f5f440f1c
commit f72ff9f812
5 changed files with 562 additions and 61 deletions

View File

@@ -2,6 +2,7 @@ package org.briarproject.bramble.api.db;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.contact.PendingContactId;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.identity.Author;
import org.briarproject.bramble.api.identity.AuthorId;
@@ -20,6 +21,9 @@ import org.briarproject.bramble.api.sync.MessageStatus;
import org.briarproject.bramble.api.sync.Offer;
import org.briarproject.bramble.api.sync.Request;
import org.briarproject.bramble.api.sync.validation.MessageState;
import org.briarproject.bramble.api.transport.StaticTransportKeySet;
import org.briarproject.bramble.api.transport.StaticTransportKeySetId;
import org.briarproject.bramble.api.transport.StaticTransportKeys;
import org.briarproject.bramble.api.transport.TransportKeySet;
import org.briarproject.bramble.api.transport.TransportKeySetId;
import org.briarproject.bramble.api.transport.TransportKeys;
@@ -119,6 +123,20 @@ public interface DatabaseComponent {
void addLocalMessage(Transaction txn, Message m, Metadata meta,
boolean shared) throws DbException;
/**
* Stores the given static transport keys for the given contact and returns
* a key set ID.
*/
StaticTransportKeySetId addStaticTransportKeys(Transaction txn, ContactId c,
StaticTransportKeys k) throws DbException;
/**
* Stores the given static transport keys for the given pending contact and
* returns a key set ID.
*/
StaticTransportKeySetId addStaticTransportKeys(Transaction txn,
PendingContactId p, StaticTransportKeys k) throws DbException;
/**
* Stores a transport.
*/
@@ -424,6 +442,14 @@ public interface DatabaseComponent {
*/
Settings getSettings(Transaction txn, String namespace) throws DbException;
/**
* Returns all static transport keys for the given transport.
* <p/>
* Read-only.
*/
Collection<StaticTransportKeySet> getStaticTransportKeys(Transaction txn,
TransportId t) throws DbException;
/**
* Returns all transport keys for the given transport.
* <p/>
@@ -432,6 +458,13 @@ public interface DatabaseComponent {
Collection<TransportKeySet> getTransportKeys(Transaction txn, TransportId t)
throws DbException;
/**
* Increments the outgoing stream counter for the given static transport
* keys.
*/
void incrementStreamCounter(Transaction txn, TransportId t,
StaticTransportKeySetId k) throws DbException;
/**
* Increments the outgoing stream counter for the given transport keys.
*/
@@ -501,6 +534,12 @@ public interface DatabaseComponent {
*/
void removeMessage(Transaction txn, MessageId m) throws DbException;
/**
* Removes the given static transport keys from the database.
*/
void removeStaticTransportKeys(Transaction txn, TransportId t,
StaticTransportKeySetId k) throws DbException;
/**
* Removes a transport (and all associated state) from the database.
*/
@@ -566,6 +605,13 @@ public interface DatabaseComponent {
void setTransportKeysActive(Transaction txn, TransportId t,
TransportKeySetId k) throws DbException;
/**
* Stores the given static transport keys, deleting any keys they have
* replaced.
*/
void updateStaticTransportKeys(Transaction txn,
Collection<StaticTransportKeySet> keys) throws DbException;
/**
* Stores the given transport keys, deleting any keys they have replaced.
*/