MCPcopy Create free account
hub / github.com/cph6/zsync / NeededByteRanges

Method NeededByteRanges

syncer.go:161–173  ·  view source on GitHub ↗

NeededByteRanges returns the byte ranges of the target file that still need to be obtained. Public for advanced use only: this is mainly used internally, but can be used by the caller if desired.

()

Source from the content-addressed store, hash-verified

159// Public for advanced use only: this is mainly used internally, but can be
160// used by the caller if desired.
161func (zs *Syncer) NeededByteRanges() []ByteRange {
162 blockRanges := zs.rs.NeededBlockRanges(0, rcksum.BlockID(zs.blocks-1))
163 byteRanges := make([]ByteRange, len(blockRanges))
164 for i, br := range blockRanges {
165 byteRanges[i].Start = int64(br.Start) * zs.blocksize
166 end := int64(br.End+1)*zs.blocksize - 1
167 if end >= zs.filelen {
168 end = zs.filelen - 1
169 }
170 byteRanges[i].End = end
171 }
172 return byteRanges
173}
174
175// SubmitTargetData takes received blocks of target data and uses them to fill
176// in missing chunks of the target file.

Callers 1

Calls 2

BlockIDTypeAlias · 0.92
NeededBlockRangesMethod · 0.80

Tested by

no test coverage detected