Skip to content

Commit

Permalink
rmv commitmetatxn (0chain#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 authored May 30, 2023
1 parent fca52bc commit 08c0e14
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 56 deletions.
2 changes: 1 addition & 1 deletion dev/blobber/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func getReference(w http.ResponseWriter, req *http.Request) {
return
}

rootRefs := `{"meta_data":{"chunk_size":0,"created_at":0,"hash":"","lookup_hash":"","name":"/","num_of_blocks":0,"path":"/","path_hash":"","size":0,"type":"d","updated_at":0},"Ref":{"ID":0,"Type":"d","AllocationID":"` + vars["allocation"] + `","LookupHash":"","Name":"/","Path":"/","Hash":"","NumBlocks":0,"PathHash":"","ParentPath":"","PathLevel":1,"CustomMeta":"","ValidationRoot":"","Size":0,"FixedMerkleRoot":"","ActualFileSize":0,"ActualFileHash":"","MimeType":"","WriteMarker":"","ThumbnailSize":0,"ThumbnailHash":"","ActualThumbnailSize":0,"ActualThumbnailHash":"","EncryptedKey":"","Children":null,"OnCloud":false,"CommitMetaTxns":null,"CreatedAt":0,"UpdatedAt":0,"ChunkSize":0},"latest_write_marker":null}`
rootRefs := `{"meta_data":{"chunk_size":0,"created_at":0,"hash":"","lookup_hash":"","name":"/","num_of_blocks":0,"path":"/","path_hash":"","size":0,"type":"d","updated_at":0},"Ref":{"ID":0,"Type":"d","AllocationID":"` + vars["allocation"] + `","LookupHash":"","Name":"/","Path":"/","Hash":"","NumBlocks":0,"PathHash":"","ParentPath":"","PathLevel":1,"CustomMeta":"","ValidationRoot":"","Size":0,"FixedMerkleRoot":"","ActualFileSize":0,"ActualFileHash":"","MimeType":"","WriteMarker":"","ThumbnailSize":0,"ThumbnailHash":"","ActualThumbnailSize":0,"ActualThumbnailHash":"","EncryptedKey":"","Children":null,"OnCloud":false,"CreatedAt":0,"UpdatedAt":0,"ChunkSize":0},"latest_write_marker":null}`

//nolint: errcheck
w.Write([]byte(rootRefs))
Expand Down
24 changes: 0 additions & 24 deletions wasmsdk/txn.go
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
package main

import "github.com/0chain/gosdk/core/transaction"

var commitMetaTxnChan = make(chan MetadataCommitResult, 10)

type MetadataCommitResult struct {
Error error
Txn *transaction.Transaction
}

func setLastMetadataCommitTxn(txn *transaction.Transaction, err error) {
go func() {
commitMetaTxnChan <- MetadataCommitResult{
Error: err,
Txn: txn,
}
}()
}

func getLastMetadataCommitTxn() (*transaction.Transaction, error) {
r := <-commitMetaTxnChan

return r.Txn, r.Error
}
19 changes: 6 additions & 13 deletions zboxcore/fileref/fileref.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ const (
DIRECTORY = "d"
)

type CommitMetaTxn struct {
RefID int64 `json:"ref_id"`
TxnID string `json:"txn_id"`
CreatedAt string `json:"created_at"`
}

type Collaborator struct {
RefID int64 `json:"ref_id"`
ClientID string `json:"client_id"`
Expand All @@ -40,13 +34,12 @@ type FileRef struct {
ActualFileSize int64 `json:"actual_file_size" mapstructure:"actual_file_size"`
ActualFileHash string `json:"actual_file_hash" mapstructure:"actual_file_hash"`
// ActualFileHashSignature is signature signed by client for ActualFileHash
ActualFileHashSignature string `json:"actual_file_hash_signature" mapstructure:"actual_file_hash_signature"`
ActualThumbnailSize int64 `json:"actual_thumbnail_size" mapstructure:"actual_thumbnail_size"`
ActualThumbnailHash string `json:"actual_thumbnail_hash" mapstructure:"actual_thumbnail_hash"`
MimeType string `json:"mimetype" mapstructure:"mimetype"`
EncryptedKey string `json:"encrypted_key" mapstructure:"encrypted_key"`
CommitMetaTxns []CommitMetaTxn `json:"commit_meta_txns" mapstructure:"commit_meta_txns"`
Collaborators []Collaborator `json:"collaborators" mapstructure:"collaborators"`
ActualFileHashSignature string `json:"actual_file_hash_signature" mapstructure:"actual_file_hash_signature"`
ActualThumbnailSize int64 `json:"actual_thumbnail_size" mapstructure:"actual_thumbnail_size"`
ActualThumbnailHash string `json:"actual_thumbnail_hash" mapstructure:"actual_thumbnail_hash"`
MimeType string `json:"mimetype" mapstructure:"mimetype"`
EncryptedKey string `json:"encrypted_key" mapstructure:"encrypted_key"`
Collaborators []Collaborator `json:"collaborators" mapstructure:"collaborators"`
}

type RefEntity interface {
Expand Down
3 changes: 0 additions & 3 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ type ConsolidatedFileMeta struct {
ActualFileSize int64
ActualNumBlocks int64
EncryptedKey string
CommitMetaTxns []fileref.CommitMetaTxn
Collaborators []fileref.Collaborator
}

Expand Down Expand Up @@ -1075,7 +1074,6 @@ func (a *Allocation) GetFileMeta(path string) (*ConsolidatedFileMeta, error) {
result.Path = ref.Path
result.Size = ref.ActualFileSize
result.EncryptedKey = ref.EncryptedKey
result.CommitMetaTxns = ref.CommitMetaTxns
result.Collaborators = ref.Collaborators
result.ActualFileSize = ref.ActualFileSize
result.ActualNumBlocks = ref.NumBlocks
Expand Down Expand Up @@ -1121,7 +1119,6 @@ func (a *Allocation) GetFileMetaFromAuthTicket(authTicket string, lookupHash str
result.MimeType = ref.MimeType
result.Path = ref.Path
result.Size = ref.ActualFileSize
result.CommitMetaTxns = ref.CommitMetaTxns
result.ActualFileSize = ref.Size
result.ActualNumBlocks = ref.NumBlocks
return result, nil
Expand Down
2 changes: 1 addition & 1 deletion zboxcore/sdk/allocation_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func setupHttpResponses(
return http.StatusBadRequest
}(),
Body: func() io.ReadCloser {
s := `{"meta_data":{"chunk_size":0,"created_at":0,"hash":"","lookup_hash":"","name":"/","num_of_blocks":0,"path":"/","path_hash":"","size":0,"type":"d","updated_at":0},"Ref":{"ID":0,"Type":"d","AllocationID":"` + allocID + `","LookupHash":"","Name":"/","Path":"/","Hash":"","NumBlocks":0,"PathHash":"","ParentPath":"","PathLevel":1,"CustomMeta":"","ContentHash":"","Size":0,"MerkleRoot":"","ActualFileSize":0,"ActualFileHash":"","MimeType":"","WriteMarker":"","ThumbnailSize":0,"ThumbnailHash":"","ActualThumbnailSize":0,"ActualThumbnailHash":"","EncryptedKey":"","Children":null,"OnCloud":false,"CommitMetaTxns":null,"CreatedAt":0,"UpdatedAt":0,"ChunkSize":0},"list":[{"meta_data":{"chunk_size":0,"created_at":0,"hash":"","lookup_hash":"","name":"1.txt","num_of_blocks":0,"path":"/1.txt","path_hash":"","size":0,"type":"f","updated_at":0},"Ref":{"ID":0,"Type":"f","AllocationID":"` + allocID + `","LookupHash":"","Name":"1.txt","Path":"/1.txt","Hash":"","NumBlocks":0,"PathHash":"","ParentPath":"/","PathLevel":1,"CustomMeta":"","ContentHash":"","Size":0,"MerkleRoot":"","ActualFileSize":0,"ActualFileHash":"","MimeType":"","WriteMarker":"","ThumbnailSize":0,"ThumbnailHash":"","ActualThumbnailSize":0,"ActualThumbnailHash":"","EncryptedKey":"","Children":null,"OnCloud":false,"CommitMetaTxns":null,"CreatedAt":0,"UpdatedAt":0,"ChunkSize":0}}],"latest_write_marker":null}`
s := `{"meta_data":{"chunk_size":0,"created_at":0,"hash":"","lookup_hash":"","name":"/","num_of_blocks":0,"path":"/","path_hash":"","size":0,"type":"d","updated_at":0},"Ref":{"ID":0,"Type":"d","AllocationID":"` + allocID + `","LookupHash":"","Name":"/","Path":"/","Hash":"","NumBlocks":0,"PathHash":"","ParentPath":"","PathLevel":1,"CustomMeta":"","ContentHash":"","Size":0,"MerkleRoot":"","ActualFileSize":0,"ActualFileHash":"","MimeType":"","WriteMarker":"","ThumbnailSize":0,"ThumbnailHash":"","ActualThumbnailSize":0,"ActualThumbnailHash":"","EncryptedKey":"","Children":null,"OnCloud":false,"CreatedAt":0,"UpdatedAt":0,"ChunkSize":0},"list":[{"meta_data":{"chunk_size":0,"created_at":0,"hash":"","lookup_hash":"","name":"1.txt","num_of_blocks":0,"path":"/1.txt","path_hash":"","size":0,"type":"f","updated_at":0},"Ref":{"ID":0,"Type":"f","AllocationID":"` + allocID + `","LookupHash":"","Name":"1.txt","Path":"/1.txt","Hash":"","NumBlocks":0,"PathHash":"","ParentPath":"/","PathLevel":1,"CustomMeta":"","ContentHash":"","Size":0,"MerkleRoot":"","ActualFileSize":0,"ActualFileHash":"","MimeType":"","WriteMarker":"","ThumbnailSize":0,"ThumbnailHash":"","ActualThumbnailSize":0,"ActualThumbnailHash":"","EncryptedKey":"","Children":null,"OnCloud":false,"CreatedAt":0,"UpdatedAt":0,"ChunkSize":0}}],"latest_write_marker":null}`
return ioutil.NopCloser(bytes.NewReader([]byte(s)))
}(),
}, nil)
Expand Down
14 changes: 0 additions & 14 deletions zboxcore/zboxutil/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const (
OBJECT_TREE_ENDPOINT = "/v1/file/objecttree/"
REFS_ENDPOINT = "/v1/file/refs/"
RECENT_REFS_ENDPOINT = "/v1/file/refs/recent/"
COMMIT_META_TXN_ENDPOINT = "/v1/file/commitmetatxn/"
COLLABORATOR_ENDPOINT = "/v1/file/collaborator/"
CALCULATE_HASH_ENDPOINT = "/v1/file/calculatehash/"
SHARE_ENDPOINT = "/v1/marketplace/shareinfo/"
Expand Down Expand Up @@ -311,19 +310,6 @@ func NewAllocationRequest(baseUrl, allocation string) (*http.Request, error) {
return req, nil
}

func NewCommitMetaTxnRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error) {
u, err := joinUrl(baseUrl, COMMIT_META_TXN_ENDPOINT, allocation)
if err != nil {
return nil, err
}
req, err := http.NewRequest(http.MethodPost, u.String(), body)
if err != nil {
return nil, err
}
setClientInfo(req)
return req, nil
}

func NewCollaboratorRequest(baseUrl string, allocation string, body io.Reader) (*http.Request, error) {
u, err := joinUrl(baseUrl, COLLABORATOR_ENDPOINT, allocation)
if err != nil {
Expand Down

0 comments on commit 08c0e14

Please sign in to comment.