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 6834b05 commit 65a0152
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions zboxcore/zboxutil/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,26 +817,30 @@ func MakeSCRestAPICall(scAddress string, relativePath string, params map[string]
return nil, err
}

var urls []string
for _, sharder := range sharders {
urlString := fmt.Sprintf("%v/%v%v%v", sharder, SC_REST_API_URL, scAddress, relativePath)
urlObj, err := url.Parse(urlString)
if err != nil {
log.Error(err)
continue
}
q := urlObj.Query()
for k, v := range params {
q.Add(k, v)
}
urlObj.RawQuery = q.Encode()
urls = append(urls, urlObj.String())
}

for _, sharder := range urls {
wg.Add(1)
go func(sharder string) {
defer wg.Done()

urlString := fmt.Sprintf("%v/%v%v%v", sharder, SC_REST_API_URL, scAddress, relativePath)
urlObj, err := url.ParseRequestURI(urlString)
if err != nil {
log.Error(err)
return
}
q := urlObj.Query()
for k, v := range params {
q.Add(k, v)
}
urlObj.RawQuery = q.Encode()
client := &http.Client{Transport: DefaultTransport}
s := urlObj.String()

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

0 comments on commit 65a0152

Please sign in to comment.