sharding/client: Adding deserialize blobs(#92)

Former-commit-id: f11427ff5b305c1f9ebb30b2436e75b5ff9a9dc9 [formerly 3def7d93a525e3bb8348de8fb24ad9d828580860]
Former-commit-id: 6dc530e57dc5a35ee50564ecc082d035f6ceead1
This commit is contained in:
nisdas 2018-05-02 13:00:37 +08:00
parent 92c44d455f
commit e88c1343d4

View File

@ -3,6 +3,7 @@ package client
import (
"fmt"
"math"
"reflect"
)
var (
@ -18,8 +19,8 @@ type collationbody []byte
type body interface {
length() int64
validateblob() error
ParseBlob()
validateBody() error
serializeBlob() []byte
}
func (cb collationbody) length() int64 {
@ -44,6 +45,24 @@ func (cb collationbody) validateBody() error {
return nil
}
func deserializeBlob(blob body) []byte {
deserializedblob := blob.(collationbody)
length := deserializedblob.length()
chunksNumber := chunkSize / length
indicatorByte := make([]byte, 1)
indicatorByte[0] = 0
tempbody := []byte{0}
for i := int64(1); i <= chunksNumber; i++ {
if reflect.TypeOf(deserializedblob[:(i-1)*chunksNumber]) == reflect.TypeOf(indicatorByte) {
}
}
}
// Parse Collation body and modify it accordingly
func (cb collationbody) serializeBlob() []byte {
@ -52,7 +71,7 @@ func (cb collationbody) serializeBlob() []byte {
chunksNumber := cb.length() / chunkDataSize
indicatorByte := make([]byte, 1)
indicatorByte[0] = 0
var tempbody []byte
tempbody := []byte{}
// if blob is less than 31 bytes, it adds the indicator chunk and pads the remaining empty bytes to the right