sharding/client: Add utils.go for blob serialization(#92)

Former-commit-id: 553671c1f1e1e1cb50c16fce53ecf0a5acc0595c [formerly 454f56eb8103b7a2b341ec2852c849611c55a1c0]
Former-commit-id: 1a8305e422b5dcc1173afc0ed9d81c49ce426eb0
This commit is contained in:
nisdas 2018-04-19 01:07:39 +08:00
parent a42b4f7bfa
commit f2e110680d

39
sharding/client/utils.go Normal file
View File

@ -0,0 +1,39 @@
package client
import (
"fmt"
)
type collationbody []byte
var (
collationsizelimit = int64(2 * *20)
chunkSize = int64(32)
indicatorSize = int64(1)
chunkDataSize = chunkSize - indicatorSize
)
func (c *collationbody) validateBody() bool {
return len(c) < 2^20 && len(c) > 0
}
func createChunks(c collationbody) {
validCollation, err := c.validateBody
if err != nil {
fmt.Errorf("Error %v", err)
}
if !validCollation {
fmt.Errorf("Error %v", err)
}
index := int64(len(c)) / chunkDataSize
/*
for i = 0; i < index; i++ {
serialisedblob[i*chunksize] = 0
for f = 0; f <chunkdatasize ; f++ {
serialisedblob[(f+1) + i*chunksize] = collationbody[f + i*chunkdatasize]
}
serialisedblob[index*chunksize ] = len(collationbody) index*chunkdatasize
}*/
}