Skip to content

Commit

Permalink
Merge pull request #10 from banyancomputer/claudia/screaming
Browse files Browse the repository at this point in the history
Fix WASM usize
  • Loading branch information
organizedgrime authored Oct 25, 2023
2 parents f7ea067 + 8bf79f5 commit 55858a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wnfs-hamt/src/strategies/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn generate_changes<K: Debug + Clone, V: Debug + Clone>(
pairs
.clone()
.into_iter()
.zip(randoms.into_iter())
.zip(randoms)
.filter(|(_, (num, _))| *num != 0)
.map(|((k, _), (num, val))| match num {
1 => Change::Add(k, val),
Expand Down
8 changes: 4 additions & 4 deletions wnfs/src/private/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,14 @@ impl PrivateFile {
} => {
let mut cids = <BTreeSet<Cid>>::new();
let bare_name = &self.header.bare_name;

for label in Self::generate_shard_labels(key, 0, *block_count, bare_name) {
let label_hash = &Sha3_256::hash(&label.as_bytes());
let block_cids = forest
.get_encrypted(label_hash, store)
.await?
.ok_or(FsError::FileShardNotFound)?;
cids.extend(block_cids)
cids.extend(block_cids);
}
Ok(cids)
}
Expand All @@ -643,23 +644,22 @@ impl PrivateFile {
if index >= block_count {
return None;
}

let label = Self::create_block_label(key, index, bare_name);
index += 1;

Some(label)
})
}

/// Creates the label for a block of a file.
fn create_block_label(key: &SnapshotKey, index: usize, bare_name: &Namefilter) -> Namefilter {
let key_bytes = key.0.as_bytes();
let key_hash = Sha3_256::hash(&[key_bytes, &index.to_le_bytes()[..]].concat());
let key_hash = Sha3_256::hash(&[key_bytes, &(index as u64).to_le_bytes()[..]].concat());

let mut label = bare_name.clone();
label.add(&key_bytes);
label.add(&key_hash);
label.saturate();

label
}

Expand Down

0 comments on commit 55858a9

Please sign in to comment.