Skip to content

Commit ec2408c

Browse files
author
nisdas
committed
sharding/client: Adding deserialize blobs(ethereum#92)
1 parent c01612f commit ec2408c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

sharding/client/utils.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package client
33
import (
44
"fmt"
55
"math"
6+
"reflect"
67
)
78

89
var (
@@ -18,8 +19,8 @@ type collationbody []byte
1819

1920
type body interface {
2021
length() int64
21-
validateblob() error
22-
ParseBlob()
22+
validateBody() error
23+
serializeBlob() []byte
2324
}
2425

2526
func (cb collationbody) length() int64 {
@@ -44,6 +45,24 @@ func (cb collationbody) validateBody() error {
4445
return nil
4546
}
4647

48+
func deserializeBlob(blob body) []byte {
49+
deserializedblob := blob.(collationbody)
50+
length := deserializedblob.length()
51+
chunksNumber := chunkSize / length
52+
indicatorByte := make([]byte, 1)
53+
indicatorByte[0] = 0
54+
tempbody := []byte{0}
55+
56+
for i := int64(1); i <= chunksNumber; i++ {
57+
58+
if reflect.TypeOf(deserializedblob[:(i-1)*chunksNumber]) == reflect.TypeOf(indicatorByte) {
59+
60+
}
61+
62+
}
63+
64+
}
65+
4766
// Parse Collation body and modify it accordingly
4867

4968
func (cb collationbody) serializeBlob() []byte {
@@ -52,7 +71,7 @@ func (cb collationbody) serializeBlob() []byte {
5271
chunksNumber := cb.length() / chunkDataSize
5372
indicatorByte := make([]byte, 1)
5473
indicatorByte[0] = 0
55-
var tempbody []byte
74+
tempbody := []byte{}
5675

5776
// if blob is less than 31 bytes, it adds the indicator chunk and pads the remaining empty bytes to the right
5877

0 commit comments

Comments
 (0)