Skip to content

Commit ec15cad

Browse files
committed
add encryption version
1 parent 81d202b commit ec15cad

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

code/go/0chain.net/blobbercore/allocation/file_changer_base.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ type BaseFileChanger struct {
5252
EncryptedKeyPoint string `json:"encrypted_key_point,omitempty"`
5353
CustomMeta string `json:"custom_meta,omitempty"`
5454

55-
ChunkSize int64 `json:"chunk_size,omitempty"` // the size of achunk. 64*1024 is default
56-
IsFinal bool `json:"is_final,omitempty"` // current chunk is last or not
57-
SignatureVersion int `json:"signature_version,omitempty"`
55+
ChunkSize int64 `json:"chunk_size,omitempty"` // the size of achunk. 64*1024 is default
56+
IsFinal bool `json:"is_final,omitempty"` // current chunk is last or not
57+
SignatureVersion int `json:"signature_version,omitempty"`
58+
EncryptionVersion int `json:"encryption_version,omitempty"`
5859

5960
ChunkStartIndex int `json:"chunk_start_index,omitempty"` // start index of chunks.
6061
ChunkEndIndex int `json:"chunk_end_index,omitempty"` // end index of chunks. all chunks MUST be uploaded one by one because of CompactMerkleTree

code/go/0chain.net/blobbercore/allocation/file_changer_update.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func (nf *UpdateFileChanger) ApplyChange(ctx context.Context, rootRef *reference
107107
fileRef.IsPrecommit = true
108108
fileRef.FilestoreVersion = filestore.VERSION
109109
fileRef.SignatureVersion = nf.SignatureVersion
110+
fileRef.EncryptionVersion = nf.EncryptionVersion
110111

111112
return rootRef, nil
112113
}
@@ -175,6 +176,7 @@ func (nf *UpdateFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot,
175176
NumBlocks: int64(math.Ceil(float64(nf.Size*1.0) / float64(nf.ChunkSize))),
176177
NumUpdates: refResult.NumUpdates + 1,
177178
SignatureVersion: nf.SignatureVersion,
179+
EncryptionVersion: nf.EncryptionVersion,
178180
}
179181
nf.storageVersion = 1
180182
newFile.FileMetaHash = encryption.Hash(newFile.GetFileMetaHashDataV2())

code/go/0chain.net/blobbercore/allocation/file_changer_upload.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func (nf *UploadFileChanger) applyChange(ctx context.Context, rootRef *reference
131131
IsPrecommit: true,
132132
FilestoreVersion: filestore.VERSION,
133133
SignatureVersion: nf.SignatureVersion,
134+
EncryptionVersion: nf.EncryptionVersion,
134135
}
135136

136137
fileID, ok := fileIDMeta[newFile.Path]
@@ -199,6 +200,7 @@ func (nf *UploadFileChanger) ApplyChangeV2(ctx context.Context, allocationRoot,
199200
NumBlocks: int64(math.Ceil(float64(nf.Size*1.0) / float64(nf.ChunkSize))),
200201
NumUpdates: 1,
201202
SignatureVersion: nf.SignatureVersion,
203+
EncryptionVersion: nf.EncryptionVersion,
202204
}
203205
nf.storageVersion = 1
204206
newFile.FileMetaHash = encryption.Hash(newFile.GetFileMetaHashDataV2())

code/go/0chain.net/blobbercore/reference/ref.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type Ref struct {
9393
NumBlockDownloads int64 `gorm:"column:num_of_block_downloads" json:"num_of_block_downloads"`
9494
FilestoreVersion int `gorm:"column:filestore_version" json:"-"`
9595
SignatureVersion int `gorm:"column:signature_version" json:"signature_version" filelist:"signature_version"`
96+
EncryptionVersion int `gorm:"column:encryption_version" json:"encryption_version" filelist:"encryption_version"`
9697
IsEmpty bool `gorm:"-" dirlist:"is_empty"`
9798
HashToBeComputed bool `gorm:"-"`
9899
prevID int64 `gorm:"-"`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
4+
ALTER TABLE reference_objects ADD COLUMN encryption_version smallint;
5+
6+
-- +goose StatementEnd

0 commit comments

Comments
 (0)