Skip to content

Commit

Permalink
Added changes for update blobber request and newAllocationBlobbers =
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Mar 20, 2024
1 parent 9924dfe commit 927bf43
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mobilesdk/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (s *StorageSDK) UpdateAllocation(size int64, extend bool, allocationID stri
return "", errors.Errorf("int64 overflow in lock")
}

hash, _, err = sdk.UpdateAllocation(size, extend, allocationID, lock, "", "", false, &sdk.FileOptionsParameters{})
hash, _, err = sdk.UpdateAllocation(size, extend, allocationID, lock, "", "", "", false, &sdk.FileOptionsParameters{})
return hash, err
}

Expand Down
10 changes: 6 additions & 4 deletions wasmsdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func createfreeallocation(freeStorageMarker string) (string, error) {

func getAllocationBlobbers(preferredBlobberURLs []string,
dataShards, parityShards int, size int64,
minReadPrice, maxReadPrice, minWritePrice, maxWritePrice int64, force bool) ([]string, error) {
minReadPrice, maxReadPrice, minWritePrice, maxWritePrice int64, isRestricted, force bool) ([]string, error) {

if len(preferredBlobberURLs) > 0 {
return sdk.GetBlobberIds(preferredBlobberURLs)
Expand All @@ -57,7 +57,7 @@ func getAllocationBlobbers(preferredBlobberURLs []string,
}, sdk.PriceRange{
Min: uint64(minWritePrice),
Max: uint64(maxWritePrice),
}, force)
}, isRestricted, force)
}

func createAllocation(datashards, parityshards int, size int64,
Expand Down Expand Up @@ -122,6 +122,7 @@ func UpdateForbidAllocation(allocationID string, forbidupload, forbiddelete, for
allocationID, // allocID,
0, //lock,
"", //addBlobberId,
"", //addBlobberAuthTicket
"", //removeBlobberId,
false, //thirdPartyExtendable,
&sdk.FileOptionsParameters{
Expand All @@ -146,6 +147,7 @@ func freezeAllocation(allocationID string) (string, error) {
allocationID, // allocID,
0, //lock,
"", //addBlobberId,
"", //addBlobberAuthTicket
"", //removeBlobberId,
false, //thirdPartyExtendable,
&sdk.FileOptionsParameters{
Expand Down Expand Up @@ -206,8 +208,8 @@ func updateAllocationWithRepair(allocationID string,
func updateAllocation(allocationID string,
size int64, extend bool,
lock int64,
addBlobberId, removeBlobberId string, setThirdPartyExtendable bool) (string, error) {
hash, _, err := sdk.UpdateAllocation(size, extend, allocationID, uint64(lock), addBlobberId, removeBlobberId, setThirdPartyExtendable, &sdk.FileOptionsParameters{})
addBlobberId, addBlobberAuthTicket, removeBlobberId string, setThirdPartyExtendable bool) (string, error) {
hash, _, err := sdk.UpdateAllocation(size, extend, allocationID, uint64(lock), addBlobberId, addBlobberAuthTicket, removeBlobberId, setThirdPartyExtendable, &sdk.FileOptionsParameters{})

if err == nil {
clearAllocation(allocationID)
Expand Down
4 changes: 2 additions & 2 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,7 @@ func (a *Allocation) UpdateWithRepair(
size int64,
extend bool,
lock uint64,
addBlobberId, removeBlobberId string,
addBlobberId, addBlobberAuthTicket, removeBlobberId string,
setThirdPartyExtendable bool, fileOptionsParams *FileOptionsParameters,
statusCB StatusCallback,
) (string, error) {
Expand All @@ -2479,7 +2479,7 @@ func (a *Allocation) UpdateWithRepair(
}

l.Logger.Info("Updating allocation")
hash, _, err := UpdateAllocation(size, extend, a.ID, lock, addBlobberId, removeBlobberId, setThirdPartyExtendable, fileOptionsParams)
hash, _, err := UpdateAllocation(size, extend, a.ID, lock, addBlobberId, addBlobberAuthTicket, removeBlobberId, setThirdPartyExtendable, fileOptionsParams)
if err != nil {
return "", err
}
Expand Down
8 changes: 5 additions & 3 deletions zboxcore/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ func CreateAllocationForOwner(
func GetAllocationBlobbers(
datashards, parityshards int,
size int64,
readPrice, writePrice PriceRange,
readPrice, writePrice PriceRange, isRestricted bool,
force ...bool,
) ([]string, error) {
var allocationRequest = map[string]interface{}{
Expand All @@ -1080,6 +1080,7 @@ func GetAllocationBlobbers(
"size": size,
"read_price_range": readPrice,
"write_price_range": writePrice,
"is_restricted": isRestricted,
}

allocationData, _ := json.Marshal(allocationRequest)
Expand Down Expand Up @@ -1111,7 +1112,7 @@ func getNewAllocationBlobbers(
preferredBlobberIds, blobberAuthTickets []string,
) (map[string]interface{}, error) {
allocBlobberIDs, err := GetAllocationBlobbers(
datashards, parityshards, size, readPrice, writePrice,
datashards, parityshards, size, readPrice, writePrice, false,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1247,7 +1248,7 @@ func UpdateAllocation(
extend bool,
allocationID string,
lock uint64,
addBlobberId, removeBlobberId string,
addBlobberId, addBlobberAuthTicket, removeBlobberId string,
setThirdPartyExtendable bool, fileOptionsParams *FileOptionsParameters,
) (hash string, nonce int64, err error) {

Expand All @@ -1271,6 +1272,7 @@ func UpdateAllocation(
updateAllocationRequest["size"] = size
updateAllocationRequest["extend"] = extend
updateAllocationRequest["add_blobber_id"] = addBlobberId
updateAllocationRequest["add_blobber_auth_ticket"] = addBlobberAuthTicket
updateAllocationRequest["remove_blobber_id"] = removeBlobberId
updateAllocationRequest["set_third_party_extendable"] = setThirdPartyExtendable
updateAllocationRequest["file_options_changed"], updateAllocationRequest["file_options"] = calculateAllocationFileOptions(alloc.FileOptions, fileOptionsParams)
Expand Down

0 comments on commit 927bf43

Please sign in to comment.