Skip to content

Commit

Permalink
Merge pull request #1582 from 0chain/hotfix/list-all
Browse files Browse the repository at this point in the history
list only if consensus thresh is not met
  • Loading branch information
dabasov authored Aug 21, 2024
2 parents 95591c8 + 53d7a2f commit daa6e32
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zboxcore/sdk/listworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,14 @@ func (req *ListRequest) getlistFromBlobbers() ([]*listResponse, error) {
listInfos := make([]*listResponse, numList)
consensusMap := make(map[string][]*blockchain.StorageNode)
var consensusHash string
errCnt := 0
for i := 0; i < numList; i++ {
listInfos[i] = <-rspCh
if !req.forRepair {
if listInfos[i].err != nil || listInfos[i].ref == nil {
if listInfos[i].err != nil {
errCnt++
}
continue
}
hash := listInfos[i].ref.FileMetaHash
Expand All @@ -186,11 +190,15 @@ func (req *ListRequest) getlistFromBlobbers() ([]*listResponse, error) {
}

var err error
req.listOnly = true
listLen := len(consensusMap[consensusHash])
if listLen < req.consensusThresh {
if req.fullconsensus-errCnt >= req.consensusThresh && !req.listOnly {
req.listOnly = true
return req.getlistFromBlobbers()
}
return listInfos, listInfos[0].err
}
req.listOnly = true
listInfos = listInfos[:1]
listOnlyRespCh := make(chan *listResponse, 1)
for i := 0; i < listLen; i++ {
Expand Down

0 comments on commit daa6e32

Please sign in to comment.