Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/go/0chain.net/blobbercore/allocation/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Allocation struct {
LatestRedeemedWM string `gorm:"column:latest_redeemed_write_marker"`
IsRedeemRequired bool `gorm:"column:is_redeem_required"`
TimeUnit time.Duration `gorm:"column:time_unit"`
IsImmutable bool `gorm:"is_immutable"`
// Ending and cleaning
CleanedUp bool `gorm:"column:cleaned_up"`
Finalized bool `gorm:"column:finalized"`
Expand Down
1 change: 1 addition & 0 deletions code/go/0chain.net/blobbercore/allocation/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func VerifyAllocationTransaction(ctx context.Context, allocationTx string,
a.UsedSize = sa.UsedSize
a.Finalized = sa.Finalized
a.TimeUnit = sa.TimeUnit
a.IsImmutable = sa.IsImmutable

// related terms
a.Terms = make([]*Terms, 0, len(sa.BlobberDetails))
Expand Down
21 changes: 21 additions & 0 deletions code/go/0chain.net/blobbercore/handler/object_operation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ func (fsh *StorageHandler) CommitWrite(ctx context.Context, r *http.Request) (*C
return nil, common.NewError("invalid_parameters", "Invalid allocation id passed."+err.Error())
}

if allocationObj.IsImmutable {
return nil, common.NewError("immutable_allocation", "Cannot write to an immutable allocation")
}

allocationID := allocationObj.ID

connectionID := r.FormValue("connection_id")
Expand Down Expand Up @@ -585,6 +589,11 @@ func (fsh *StorageHandler) RenameObject(ctx context.Context, r *http.Request) (i
if err != nil {
return nil, common.NewError("invalid_parameters", "Invalid allocation id passed."+err.Error())
}

if allocationObj.IsImmutable {
return nil, common.NewError("immutable_allocation", "Cannot rename data in an immutable allocation")
}

allocationID := allocationObj.ID

clientID := ctx.Value(constants.CLIENT_CONTEXT_KEY).(string)
Expand Down Expand Up @@ -683,6 +692,10 @@ func (fsh *StorageHandler) UpdateObjectAttributes(ctx context.Context,
return nil, common.NewError("invalid_signature", "Invalid signature")
}

if alloc.IsImmutable {
return nil, common.NewError("immutable_allocation", "Cannot update data in an immutable allocation")
}

// runtime type check
_ = ctx.Value(constants.CLIENT_KEY_CONTEXT_KEY).(string)

Expand Down Expand Up @@ -779,6 +792,10 @@ func (fsh *StorageHandler) CopyObject(ctx context.Context, r *http.Request) (int
return nil, common.NewError("invalid_signature", "Invalid signature")
}

if allocationObj.IsImmutable {
return nil, common.NewError("immutable_allocation", "Cannot copy data in an immutable allocation")
}

clientID := ctx.Value(constants.CLIENT_CONTEXT_KEY).(string)
_ = ctx.Value(constants.CLIENT_KEY_CONTEXT_KEY).(string)

Expand Down Expand Up @@ -911,6 +928,10 @@ func (fsh *StorageHandler) WriteFile(ctx context.Context, r *http.Request) (*Upl
return nil, common.NewError("invalid_signature", "Invalid signature")
}

if allocationObj.IsImmutable {
return nil, common.NewError("immutable_allocation", "Cannot write to an immutable allocation")
}

allocationID := allocationObj.ID

if len(clientID) == 0 {
Expand Down
3 changes: 2 additions & 1 deletion code/go/0chain.net/core/transaction/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type StakePoolSettings struct {
}

type StorageNodeGeolocation struct {
Latitude float64 `json:"latitude"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}

Expand Down Expand Up @@ -101,6 +101,7 @@ type StorageAllocation struct {
Finalized bool `json:"finalized"`
CCT time.Duration `json:"challenge_completion_time"`
TimeUnit time.Duration `json:"time_unit"`
IsImmutable bool `json:"is_immutable"`
}

func (sa *StorageAllocation) Until() common.Timestamp {
Expand Down
6 changes: 6 additions & 0 deletions sql/15-add-allocation-columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\connect blobber_meta;

BEGIN;
ALTER TABLE allocations ADD COLUMN repairer_id VARCHAR(64) NOT NULL;
ALTER TABLE allocations ADD COLUMN is_immutable BOOLEAN NOT NULL;
COMMIT;