forked from TrueCloudLab/frostfs-node
[#1616] getsvc: Simplify buildChainRange()
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
c8acdf40bb
commit
b309b34bfc
1 changed files with 7 additions and 17 deletions
|
@ -70,30 +70,20 @@ func (a *assembler) buildChainRange(ctx context.Context, prevID oid.ID) ([]oid.I
|
|||
return nil, nil, errParentAddressDiffers
|
||||
}
|
||||
|
||||
sz := head.PayloadSize()
|
||||
|
||||
a.currentOffset -= sz
|
||||
|
||||
if a.currentOffset < to {
|
||||
off := uint64(0)
|
||||
if from > a.currentOffset {
|
||||
off = from - a.currentOffset
|
||||
sz -= from - a.currentOffset
|
||||
}
|
||||
|
||||
if to < a.currentOffset+off+sz {
|
||||
sz = to - off - a.currentOffset
|
||||
}
|
||||
|
||||
nextOffset := a.currentOffset - head.PayloadSize()
|
||||
clampedFrom := max(from, nextOffset)
|
||||
clampedTo := min(to, a.currentOffset)
|
||||
if clampedFrom < clampedTo {
|
||||
index := len(rngs)
|
||||
rngs = append(rngs, objectSDK.Range{})
|
||||
rngs[index].SetOffset(off)
|
||||
rngs[index].SetLength(sz)
|
||||
rngs[index].SetOffset(clampedFrom - nextOffset)
|
||||
rngs[index].SetLength(clampedTo - clampedFrom)
|
||||
|
||||
id, _ := head.ID()
|
||||
chain = append(chain, id)
|
||||
}
|
||||
|
||||
a.currentOffset = nextOffset
|
||||
prevID, hasPrev = head.PreviousID()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue