0chain / gosdk

A client SDK in Go to interface the blockchain and storage platform, and other smart contracts
MIT License
32 stars 29 forks source link

Revert to zero padding #451

Closed lpoli closed 1 year ago

lpoli commented 2 years ago

Currently with chunked upload zero padding has been removed. As per discussion in slack channels, For a blobber, it should get minimum of blockSize amount of data which is 64KB or multiple of blockSize.

Give there are n data-blobbers and blocksize is 64KB, the reading should be done as follow:

chunkSize  := n * blockSize
chunkNums := int(math.Ceil(float64(fileSize) / float64(chunkSize)))

resultantSize := chunkNums * chunkSize
numPaddings := resultantSize - fileSize

reader := io.MultiReader(originalFileReader, bytes.NewReader(make([]byte, numPaddings)))
guruhubb commented 2 years ago

Is this same as https://github.com/0chain/gosdk/issues/426?

cnlangzi commented 2 years ago

@guruhubb yes. it is same as https://github.com/0chain/gosdk/issues/426

lpoli commented 1 year ago

The requirement is to have minimum block size i.e. 64KB. We can apply this requirement with pricing i.e. minimum cost shall be cost of 64KB. So it should be like this: If writemarker has size S and write price is W then cost of writing S bytes = Ceil_Of(S / 64KB) * W

@dabasov Please let us know if you think otherwise

dabasov commented 1 year ago

related to https://github.com/0chain/0chain/issues/1816