Skip to content

Commit 8e3061a

Browse files
fix(filecoin-proofs): appropriate padding when unsealing
1 parent f19e1e5 commit 8e3061a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

filecoin-proofs/src/api/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ pub fn get_unsealed_range<T: Into<PathBuf> + AsRef<Path>>(
7676
porep_config.window_size_nodes,
7777
);
7878

79+
let offset_padded: PaddedBytesAmount = UnpaddedBytesAmount::from(offset).into();
80+
let num_bytes_padded: PaddedBytesAmount = num_bytes.into();
81+
7982
let unsealed = StackedDrg::<DefaultTreeHasher, DefaultPieceHasher>::extract_range(
8083
&pp,
8184
&replica_id,
8285
&data,
8386
Some(config),
84-
offset.into(),
85-
num_bytes.into(),
87+
offset_padded.into(),
88+
num_bytes_padded.into(),
8689
)?;
8790

8891
let written = write_unpadded(&unsealed, &mut buf_writer, offset.into(), num_bytes.into())?;

filecoin-proofs/src/types/bytes_amount.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ impl From<UnpaddedBytesAmount> for UnpaddedByteIndex {
6060
}
6161
}
6262

63+
impl From<UnpaddedByteIndex> for UnpaddedBytesAmount {
64+
fn from(n: UnpaddedByteIndex) -> Self {
65+
UnpaddedBytesAmount(n.0)
66+
}
67+
}
68+
6369
impl From<UnpaddedByteIndex> for u64 {
6470
fn from(n: UnpaddedByteIndex) -> Self {
6571
n.0

0 commit comments

Comments
 (0)