Add input stream that fetches blocks from the DB.

This commit is contained in:
akwizgran
2018-12-05 15:32:12 +00:00
parent a5c9e7c74d
commit c6f460a936
6 changed files with 420 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package org.briarproject.bramble.api.io;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.sync.MessageId;
public interface BlockSource {
int getBlockCount(MessageId m) throws DbException;
byte[] getBlock(MessageId m, int blockNumber) throws DbException;
}

View File

@@ -0,0 +1,17 @@
package org.briarproject.bramble.api.io;
import org.briarproject.bramble.api.sync.MessageId;
import java.io.IOException;
import java.io.InputStream;
public interface MessageInputStreamFactory {
/**
* Returns an {@link InputStream} for reading the given message from the
* database. This method returns immediately. If the message is not in the
* database or cannot be read, reading from the stream will throw an
* {@link IOException};
*/
InputStream getMessageInputStream(MessageId m);
}