Skip to content

Commit

Permalink
increase time gap for auth ticket and check for final
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 committed Oct 19, 2024
1 parent 1a881b8 commit 768cdbd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions code/go/0chain.net/blobbercore/allocation/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ func DeleteConnectionObjEntry(connectionID string) {
connectionObj, ok := connectionProcessor[connectionID]
if ok {
connectionObj.cnclCtx()
for _, change := range connectionObj.changes {
if change.seqPQ != nil {
change.seqPQ.Done(seqpriorityqueue.UploadData{}, 1)
}
}
}
delete(connectionProcessor, connectionID)
connectionObjMutex.Unlock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ func (fc *BaseFileChanger) DeleteTempFile() error {
}

func (fc *BaseFileChanger) CommitToFileStore(ctx context.Context, mut *sync.Mutex) error {

if !fc.IsFinal {
return nil
}
if fc.ThumbnailSize > 0 {
fileInputData := &filestore.FileInputData{
StorageVersion: fc.storageVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func (nf *UpdateFileChanger) ApplyChange(ctx context.Context, rootRef *reference
if err != nil {
return nil, err
}
if !nf.IsFinal {
return rootRef, nil
}

rootRef.HashToBeComputed = true
rootRef.UpdatedAt = ts
Expand Down Expand Up @@ -114,6 +117,9 @@ func (nf *UpdateFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot,
if nf.AllocationID == "" {
return 0, common.NewError("invalid_allocation_id", "Allocation ID is empty")
}
if !nf.IsFinal {
return 0, nil
}

nf.LookupHash = reference.GetReferenceLookup(nf.AllocationID, nf.Path)

Expand Down Expand Up @@ -190,6 +196,9 @@ func (nf *UpdateFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot,
}

func (nf *UpdateFileChanger) CommitToFileStore(ctx context.Context, mut *sync.Mutex) error {
if !nf.IsFinal {
return nil
}
return nf.BaseFileChanger.CommitToFileStore(ctx, mut)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type UploadFileChanger struct {
func (nf *UploadFileChanger) applyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange,
allocationRoot string, ts common.Timestamp, fileIDMeta map[string]string) (*reference.Ref, error) {

if !nf.IsFinal {
return rootRef, nil
}

totalRefs, err := reference.CountRefs(ctx, nf.AllocationID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -148,6 +152,10 @@ func (nf *UploadFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot,
if nf.AllocationID == "" {
return 0, common.NewError("invalid_allocation_id", "Allocation ID is empty")
}
if !nf.IsFinal {
return 0, nil
}

//find if ref exists
var refResult struct {
ID int64
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/blobbercore/readmarker/authticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (authToken *AuthTicket) Verify(allocationObj *allocation.Allocation, client
if authToken.OwnerID != allocationObj.OwnerID {
return common.NewError("invalid_parameters", "Invalid auth ticket. Owner ID mismatch")
}
if authToken.Timestamp > (common.Now() + 2) {
if authToken.Timestamp > (common.Now() + 120) {
return common.NewError("invalid_parameters", "Invalid auth ticket. Timestamp in future")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func (pq *SeqPriorityQueue) Push(v UploadData) {
}

func (pq *SeqPriorityQueue) Done(v UploadData, dataSize int64) {
if pq.done {
return
}
pq.lock.Lock()
pq.done = true
pq.dataSize = dataSize
Expand Down

0 comments on commit 768cdbd

Please sign in to comment.