Avoid generating download batches with an invalid range
Previously, if we rounded down the tree size to avoid downloading a partial tile, but the log position was already within the partial tile (which can happen with a brand new log and -start_at_end), we'd generate a download batch where end < begin, which caused all sorts of problems.
This commit is contained in:
parent
5769c83cf3
commit
344df03c6c
|
@ -374,6 +374,10 @@ func generateBatches(ctx context.Context, ctlog *loglist.Log, position uint64, n
|
|||
// Round down to the tile boundary to avoid downloading a partial tile that was recently discovered
|
||||
// In a future invocation of this function, either enough time will have passed that this code path will be skipped, or the log will have grown and treeSize will be rounded to a larger tile boundary
|
||||
treeSize -= treeSize % ctclient.StaticTileWidth
|
||||
if treeSize < position {
|
||||
// This can arise with a brand new log when config.StartAtEnd is true
|
||||
return position, number, nil
|
||||
}
|
||||
}
|
||||
for {
|
||||
batch := &batch{
|
||||
|
|
Loading…
Reference in New Issue