pub fn truncate_ranges(ranges: &ChunkRangesRef, size: u64) -> &ChunkRangesRef
Expand description
Given a set of chunk ranges, adapt them for a tree of the given size.
This will consider anything behind the tree size to be a request for the last chunk, which makes things a bit more complex. This is useful to get a size proof for a blob of an unknown size.
If you don’t need this, you can just split the ranges on the tree size and then keep the first part.
Examples:
assuming a size of 7 chunks:
0..6 will remain 0..6 0..7 will become 0.. (the entire blob) 0..10, 11.12 will become 0.. (the entire blob) 0..6, 7..10 will become 0.. (the entire blob). the last chunk will be included and the hole filled 3..6, 7..10 will become 3.. the last chunk will be included and the hole filled 0..5, 7..10 will become 0..5, 7.. (the last chunk will be included, but chunkk 5 will not be sent)