Skip to content

Commit

Permalink
Merge pull request #1590 from 0chain/feat/repair-progress
Browse files Browse the repository at this point in the history
Repair progress
  • Loading branch information
dabasov authored Sep 1, 2024
2 parents 5aaea06 + f036437 commit e5ddf91
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wasmsdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"strings"
"sync"
"syscall/js"

"github.com/0chain/gosdk/core/transaction"
"github.com/0chain/gosdk/wasmsdk/jsbridge"
Expand Down Expand Up @@ -240,7 +241,7 @@ func updateAllocationWithRepair(allocationID string,
size int64,
extend bool,
lock int64,
addBlobberId, addBlobberAuthTicket, removeBlobberId string) (string, error) {
addBlobberId, addBlobberAuthTicket, removeBlobberId, callbackFuncName string) (string, error) {
sdk.SetWasm()
allocationObj, err := sdk.GetAllocation(allocationID)
if err != nil {
Expand All @@ -250,6 +251,12 @@ func updateAllocationWithRepair(allocationID string,
wg := &sync.WaitGroup{}
statusBar := &StatusBar{wg: wg, isRepair: true}
wg.Add(1)
if callbackFuncName != "" {
callback := js.Global().Get(callbackFuncName)
statusBar.callback = func(totalBytes, completedBytes int, filename, objURL, err string) {
callback.Invoke(totalBytes, completedBytes, filename, objURL, err)
}
}

alloc, hash, isRepairRequired, err := allocationObj.UpdateWithStatus(size, extend, uint64(lock), addBlobberId, addBlobberAuthTicket, removeBlobberId, false, &sdk.FileOptionsParameters{}, statusBar)
if err != nil {
Expand Down

0 comments on commit e5ddf91

Please sign in to comment.