Add initial stream hashing implementation.

This commit is contained in:
akwizgran
2018-12-06 17:22:34 +00:00
parent 4b04e6a21d
commit bd9ebe75a0
8 changed files with 187 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package org.briarproject.bramble.api.sync;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.sync.tree.TreeHash;
@NotNullByDefault
public interface MessageFactory {
@@ -10,4 +11,6 @@ public interface MessageFactory {
Message createMessage(byte[] raw);
byte[] getRawMessage(Message m);
MessageId getMessageId(GroupId g, long timestamp, TreeHash rootHash);
}

View File

@@ -0,0 +1,23 @@
package org.briarproject.bramble.api.sync.tree;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.io.BlockSink;
import org.briarproject.bramble.api.io.HashingId;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.bramble.api.sync.MessageId;
import java.io.IOException;
import java.io.InputStream;
@NotNullByDefault
public interface StreamHasher {
/**
* Reads the given input stream, divides the data into blocks, stores
* the blocks and the resulting hash tree using the given block sink and
* temporary ID, and returns the message ID.
*/
MessageId hash(InputStream in, BlockSink sink, HashingId h, GroupId g,
long timestamp) throws IOException, DbException;
}

View File

@@ -1,5 +1,8 @@
package org.briarproject.bramble.api.sync.tree;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
@NotNullByDefault
public interface TreeHasher {
LeafNode hashBlock(int blockNumber, byte[] data);