Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase time gap #1481

Open
wants to merge 4 commits into
base: sprint-1.18
Choose a base branch
from
Open
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestBlobberCore_FileChangerUpload(t *testing.T) {
Size: 2310,
ChunkSize: 65536,
ConnectionID: "connection_id",
IsFinal: true,
},
}

Expand Down
2 changes: 2 additions & 0 deletions code/go/0chain.net/blobbercore/allocation/multiop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func uploadChanges(allocationID, validationRoot string, fileIDMeta map[string]st
ValidationRoot: validationRoot,
Size: 2310,
ChunkSize: 65536,
IsFinal: true,
},
}
fileIDMeta[filepath.Join("/", change.Filename)] = randName()
Expand All @@ -111,6 +112,7 @@ func getUpdateChange(uploadChanger *UploadFileChanger) *UpdateFileChanger {
ValidationRoot: "updated_validation_root",
Size: uploadChanger.Size,
ChunkSize: uploadChanger.ChunkSize,
IsFinal: true,
},
}
}
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
Loading