Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
dabasov committed Nov 15, 2023
1 parent 48cf793 commit 8446894
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions zboxcore/zboxutil/http.go
Expand Up @@ -801,6 +801,8 @@ func NewRollbackRequest(baseUrl, allocationID string, allocationTx string, body
return req, nil
}

var lock sync.Mutex

func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]string, handler SCRestAPIHandler) ([]byte, error) {
numSharders := len(blockchain.GetSharders())
sharders := blockchain.GetSharders()
Expand All @@ -821,10 +823,11 @@ func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]
wg.Add(1)
go func(sharder string) {
defer wg.Done()

lock.Lock()
urlString := fmt.Sprintf("%v/%v%v%v", sharder, SC_REST_API_URL, scAddress, relativePath)
urlObj, err := url.Parse(urlString)
urlObj, err := url.ParseRequestURI(urlString)
if err != nil {
log.Error(urlString)
log.Error(err)
return
}
Expand All @@ -834,7 +837,10 @@ func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]
}
urlObj.RawQuery = q.Encode()
client := &http.Client{Transport: DefaultTransport}
response, err := client.Get(urlObj.String())
s := urlObj.String()
lock.Unlock()

response, err := client.Get(s)
if err != nil {
blockchain.Sharders.Fail(sharder)
return
Expand Down

0 comments on commit 8446894

Please sign in to comment.