FILE *fp;
if(NULL==file_p) { return -1; }
+
+ // check that piece length is >=16kb and a power of 2
if((piece_length<16384)||(piece_length&&(piece_length&(piece_length-1)))) {
return -1;
}
return -1;
}
+ /* generate piece_layers
+ * 1. grab all data and hash
+ * 2. generate piece layer merkle trees (padding to piece layer boundary)
+ * 3. generate merkle root from piece layer roots (balancing tree in process)
+ */
p = NULL;
while(1) {
size_t len = fread(data,sizeof(uint8_t),BLOCK_SIZE,fp);
fclose(fp);
+ // pad to appropiate piece layer size
+ // i.e. so each piece layer tree is balanced
+
int ratio = piece_length / BLOCK_SIZE;
while(ratio>1) {
if(block_merkle_layer(file_p->piece_layers)<0) { return -1; }