From 3e806148173897060e3144f8011d3056182970dd Mon Sep 17 00:00:00 2001 From: Hitenjain14 <57557631+Hitenjain14@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:09:21 +0530 Subject: [PATCH] select all blobbers if read is free (#1398) * select all blobbers if read is free * fix remaining mask --- zboxcore/sdk/allocation.go | 3 +++ zboxcore/sdk/downloadworker.go | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/zboxcore/sdk/allocation.go b/zboxcore/sdk/allocation.go index 649d554cf..a1d9c8d56 100644 --- a/zboxcore/sdk/allocation.go +++ b/zboxcore/sdk/allocation.go @@ -1151,6 +1151,9 @@ func (a *Allocation) processReadMarker(drs []*DownloadRequest) { wg.Add(1) go func(dr *DownloadRequest) { defer wg.Done() + if isReadFree { + dr.freeRead = true + } dr.processDownloadRequest() var pos uint64 if !dr.skip { diff --git a/zboxcore/sdk/downloadworker.go b/zboxcore/sdk/downloadworker.go index 2937e2644..1cf1a06ec 100644 --- a/zboxcore/sdk/downloadworker.go +++ b/zboxcore/sdk/downloadworker.go @@ -80,6 +80,7 @@ type DownloadRequest struct { size int64 offset int64 bufferMap map[int]*zboxutil.DownloadBuffer + freeRead bool } type blockData struct { @@ -179,7 +180,11 @@ func (req *DownloadRequest) downloadBlock( skipDownload bool ) - for i := req.downloadMask; !i.Equals64(0); i = i.And(zboxutil.NewUint128(1).Lsh(pos).Not()) { + for i := mask; !i.Equals64(0); i = i.And(zboxutil.NewUint128(1).Lsh(pos).Not()) { + if c == requiredDownloads { + remainingMask = i + break + } pos = uint64(i.TrailingZeros()) blockDownloadReq := &BlockDownloadRequest{ allocationID: req.allocationID, @@ -220,10 +225,6 @@ func (req *DownloadRequest) downloadBlock( } c++ - if c == requiredDownloads { - remainingMask = i - break - } } var failed int32 @@ -1025,6 +1026,9 @@ func (req *DownloadRequest) getFileMetaConsensus(fMetaResp []*fileMetaResponse) if countThreshold > req.fullconsensus { countThreshold = req.consensusThresh } + if req.freeRead { + countThreshold = req.fullconsensus + } for i := 0; i < len(fMetaResp); i++ { fmr := fMetaResp[i] if fmr.err != nil || fmr.fileref == nil {