github.com/0chain/gosdk@v1.17.11/docs/uml/upload.puml (about)

     1  
     2  @startuml continuous upload
     3  
     4  
     5  CLI -> gosdk:create cmd with chunk flag
     6  
     7  gosdk -> cache: check status ~/.zcn/cache/
     8  gosdk <- cache: connection_id and offset
     9  
    10  gosdk -> UploadHandler: send `INIT` request if offset is 0 with 1st chunk and thumbnail if it has
    11  UploadHandler -> StorageHandler: WriteFile
    12  StorageHandler -> FileStore: Verify allocation, and call WriteFile 
    13  FileStore -> FileSystem: Write chunk to temp file
    14  FileStore <- FileSystem: FileRef with merkle leave hash
    15  StorageHandler <- FileStore: FileOutputData
    16  StorageHandler -> AllocationChangeProcessor: Add `InitFileChange`
    17  UploadHandler <- StorageHandler: UploadResult
    18  gosdk <- UploadHandler: UploadResult
    19  
    20  gosdk -> UploadHandler: send `APPEND` requests if offset is not 0 with next chunk
    21  UploadHandler -> StorageHandler: WriteFile
    22  StorageHandler -> FileStore: Verify allocation, and call WriteFile 
    23  FileStore -> FileSystem: Write chunk to temp file
    24  FileStore <- FileSystem: FileRef with merkle leave hash
    25  StorageHandler <- FileStore: FileOutputData
    26  StorageHandler -> AllocationChangeProcessor: Add `AppendFileChange`
    27  UploadHandler <- StorageHandler: UploadResult
    28  gosdk <- UploadHandler: UploadResult
    29  
    30  gosdk -> UploadHandler: send `FINALIZE` request with last chunk
    31  UploadHandler -> StorageHandler: WriteFile
    32  StorageHandler -> FileStore: Verify allocation, and call WriteFile 
    33  FileStore -> FileSystem: Write chunk to temp file
    34  FileStore <- FileSystem: FileRef with merkle leave and root hash
    35  StorageHandler <- FileStore: FileOutputData
    36  StorageHandler -> AllocationChangeProcessor: Add `FinalizeFileChange`
    37  UploadHandler <- StorageHandler: UploadResult
    38  gosdk <- UploadHandler: UploadResult
    39  
    40  
    41  gosdk -> CommitHandler: send `COMMIT` request 
    42  CommitHandler -> StorageHandler: call CommitWrite
    43  StorageHandler -> AllocationChangeProcessor: Verify allocation, VerifyMaker, and call ApplyChanges
    44  StorageHandler -> Store: update transaction in postgres
    45  StorageHandler -> AllocationChangeProcessor: call CommitToFileStore
    46  AllocationChangeProcessor -> FileStore: call CommitWrite
    47  FileStore -> FileSystem: rename temp file to remote file path
    48  CommitHandler <- StorageHandler: CommitResult
    49  gosdk <- CommitHandler: CommitResult
    50  cache <- gosdk: clean status
    51  CLI <- gosdk: exit cmd
    52  
    53  @enduml
    54  
    55  
    56  
    57  @startuml stream upload flow
    58  
    59  loop till done
    60  FileInput -> reedsolomon.Encoder : read bytes with datashards * 64KB or datashards *(64KB - 16 - 256)
    61  reedsolomon.Encoder --> encryption.EncryptionScheme : encrypt data, and added header (256)
    62  encryption.EncryptionScheme --> APIClient: send client data
    63  reedsolomon.Encoder -> APIClient: send client data
    64  
    65  note over APIClient,blobber
    66  WHEN:
    67  1. receive all chunks data
    68  2. recevie $batch * chunks data
    69  end note
    70  APIClient -> blobber : upload to blobber
    71  
    72  end
    73  
    74  @enduml