Skip to content

Commit

Permalink
Add auth round expiry flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Jan 13, 2025
1 parent 8be45f6 commit 09ee039
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion cmd/newallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ var newallocationCmd = &cobra.Command{
}
}

var authRoundExpiry int64
if flags.Changed("auth_round_expiry") {
authRoundExpiry, err = flags.GetInt64("auth_round_expiry")
if err != nil {
log.Fatal("invalid forbid_upload: ", err)
}
}

var allocationID string
if len(owner) == 0 {
options := sdk.CreateAllocationOptions{
Expand All @@ -267,6 +275,7 @@ var newallocationCmd = &cobra.Command{
Force: force,
IsEnterprise: isEnterprise,
StorageVersion: int(storageVersion),
AuthRoundExpiry: authRoundExpiry,
}
allocationID, _, _, err = sdk.CreateAllocationWith(options)
if err != nil {
Expand All @@ -284,7 +293,7 @@ var newallocationCmd = &cobra.Command{
}

allocationID, _, _, err = sdk.CreateAllocationForOwner(owner, ownerPublicKey, *datashards, *parityshards,
*size, readPrice, writePrice, lock, preferred_blobbers, blobber_auth_tickets, thirdPartyExtendable, isEnterprise, force, &fileOptionParams, 0)
*size, readPrice, writePrice, lock, preferred_blobbers, blobber_auth_tickets, thirdPartyExtendable, isEnterprise, force, &fileOptionParams, authRoundExpiry)
if err != nil {
log.Fatal("Error creating allocation: ", err)
}
Expand Down Expand Up @@ -366,6 +375,7 @@ func init() {
newallocationCmd.Flags().Bool("forbid_rename", false, "(default false) specify if the users cannot rename objects in this allocation")

newallocationCmd.Flags().Int64("storage_version", 0, "storaage version of allocation")
newallocationCmd.Flags().Int64("auth_round_expiry", 0, "storaage version of allocation")
}

func storeAllocation(allocationID string) {
Expand Down
13 changes: 11 additions & 2 deletions cmd/updateallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ var updateAllocationCmd = &cobra.Command{
fileOptionParams.ForbidRename.Value = forbidRename
}

var authRoundExpiry int64
if flags.Changed("auth_round_expiry") {
authRoundExpiry, err = flags.GetInt64("auth_round_expiry")
if err != nil {
log.Fatal("invalid auth_round_expiry: ", err)
}
}

if addBlobberId != "" {
allocationObj, err := sdk.GetAllocation(allocID)
if err != nil {
Expand All @@ -131,7 +139,7 @@ var updateAllocationCmd = &cobra.Command{
allocUnderRepair = true
if txnHash, err := allocationObj.UpdateWithRepair(
size,
0,
authRoundExpiry,
extend,
lock,
addBlobberId,
Expand All @@ -155,7 +163,7 @@ var updateAllocationCmd = &cobra.Command{
} else {
txnHash, _, err := sdk.UpdateAllocation(
size,
0,
authRoundExpiry,
extend,
allocID,
lock,
Expand Down Expand Up @@ -205,4 +213,5 @@ func init() {
updateAllocationCmd.Flags().Bool("forbid_copy", false, "(default false) specify if the users cannot copy object from this allocation")
updateAllocationCmd.Flags().Bool("forbid_rename", false, "(default false) specify if the users cannot rename objects in this allocation")

updateAllocationCmd.Flags().Int64("auth_round_expiry", 0, "auth round expiry in seconds")
}

0 comments on commit 09ee039

Please sign in to comment.