Skip to content

Commit

Permalink
Merge branch 'staging' into fix/get-list-from-blobbers
Browse files Browse the repository at this point in the history
  • Loading branch information
din-mukhammed authored Jun 28, 2023
2 parents 2005e4c + 7fac770 commit 150e178
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 107 deletions.
2 changes: 1 addition & 1 deletion core/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
//====== THIS IS AUTOGENERATED FILE. DO NOT MODIFY ========

package version
const VERSIONSTR = "v1.8.16-58-g520bdba8"
const VERSIONSTR = "v1.8.16-87-gc6a0e22b"

31 changes: 31 additions & 0 deletions wasmsdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,32 @@ func transferAllocation(allocationID, newOwnerId, newOwnerPublicKey string) erro
return err
}

// updateForbidAllocation updates the settings for forbid alocation
func UpdateForbidAllocation(allocationID string, forbidupload, forbiddelete, forbidupdate, forbidmove, forbidcopy, forbidrename bool) (string, error) {

hash, _, err := sdk.UpdateAllocation(
0, //size,
0, //int64(expiry/time.Second),
allocationID, // allocID,
0, //lock,
false, //updateTerms,
"", //addBlobberId,
"", //removeBlobberId,
false, //thirdPartyExtendable,
&sdk.FileOptionsParameters{
ForbidUpload: sdk.FileOptionParam{Changed: forbidupload, Value: forbidupload},
ForbidDelete: sdk.FileOptionParam{Changed: forbiddelete, Value: forbiddelete},
ForbidUpdate: sdk.FileOptionParam{Changed: forbidupdate, Value: forbidupdate},
ForbidMove: sdk.FileOptionParam{Changed: forbidmove, Value: forbidmove},
ForbidCopy: sdk.FileOptionParam{Changed: forbidcopy, Value: forbidcopy},
ForbidRename: sdk.FileOptionParam{Changed: forbidrename, Value: forbidrename},
},
)

return hash, err

}

func freezeAllocation(allocationID string) (string, error) {

hash, _, err := sdk.UpdateAllocation(
Expand Down Expand Up @@ -241,6 +267,11 @@ func lockStakePool(providerType, tokens, fee uint64, providerID string) (string,
return hash, err
}

func lockReadPool(tokens, fee uint64) (string, error) {
hash, _, err := sdk.ReadPoolLock(tokens, fee)
return hash, err
}

func unlockStakePool(providerType, fee uint64, providerID string) (int64, error) {
unstake, _, err := sdk.StakePoolUnlock(sdk.ProviderType(providerType), providerID, fee)
return unstake, err
Expand Down
14 changes: 11 additions & 3 deletions wasmsdk/blobber.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ type BulkUploadOption struct {

ThumbnailBytes jsbridge.Bytes `json:"thumbnailBytes,omitempty"`
Encrypt bool `json:"encrypt,omitempty"`
webstreaming bool `json:"webstreaming,omitempty"`
Webstreaming bool `json:"webstreaming,omitempty"`
IsUpdate bool `json:"isUpdate,omitempty"`
IsRepair bool `json:"isRepair,omitempty"`

Expand All @@ -420,6 +420,7 @@ type MultiUploadResult struct {
Success bool `json:"success,omitempty"`
Error string `json:"error,omitempty"`
}

type MultiOperationOption struct {
OperationType string `json:"operationType,omitempty"`
RemotePath string `json:"remotePath,omitempty"`
Expand All @@ -430,17 +431,23 @@ type MultiOperationOption struct {
// MultiOperation - do copy, move, delete and createdir operation together
// ## Inputs
// - allocationID
// - jsonMultiUploadOpetions: Json Array of MultiOperationOption. eg: "[{"operationType":"move","remotePath":"/README.md","destPath":"/folder1/"},{"operationType":"delete","remotePath":"/t3.txt"}]"
// - jsonMultiUploadOptions: Json Array of MultiOperationOption. eg: "[{"operationType":"move","remotePath":"/README.md","destPath":"/folder1/"},{"operationType":"delete","remotePath":"/t3.txt"}]"
//
// ## Outputs
// - error
func MultiOperation(allocationID string, jsonMultiUploadOptions string) error {
if allocationID == "" {
return errors.New("AllocationID is required")
}

if jsonMultiUploadOptions == "" {
return errors.New("operations are empty")
}

var options []MultiOperationOption
err := json.Unmarshal([]byte(jsonMultiUploadOptions), &options)
if err != nil {
sdkLogger.Info("error unmarshalling")
return err
}
totalOp := len(options)
Expand Down Expand Up @@ -481,7 +488,7 @@ func bulkUpload(jsonBulkUploadOptions string) ([]BulkUploadResult, error) {
o.ReadChunkFuncName,
o.FileSize,
o.ThumbnailBytes.Buffer,
o.webstreaming,
o.Webstreaming,
o.Encrypt,
o.IsUpdate,
o.IsRepair,
Expand All @@ -505,6 +512,7 @@ func bulkUpload(jsonBulkUploadOptions string) ([]BulkUploadResult, error) {

return results, nil
}

func multiUpload(jsonBulkUploadOptions string) (MultiUploadResult, error) {
var options []BulkUploadOption
result := MultiUploadResult{}
Expand Down
Loading

0 comments on commit 150e178

Please sign in to comment.