Skip to content

Commit

Permalink
sharding/client: Adding Main serialize function(ethereum#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas committed May 16, 2018
1 parent bf04ddb commit c1ff070
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions sharding/client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (

type txblob []byte

type body interface {
type blob interface {
length() int64
validateBody() error
serializeBlob() []byte
Expand Down Expand Up @@ -45,12 +45,12 @@ func (cb txblob) validateBody() error {
return nil
}

func deserializebody(collationbody []byte) []body {
func deserializebody(collationbody []byte) []blob {
length := int64(len(collationbody))
chunksNumber := chunkSize / length
indicatorByte := make([]byte, 1)
indicatorByte[0] = 0
txblobs := []body{}
txblobs := []blob{}
var tempbody txblob

for i := int64(1); i <= chunksNumber; i++ {
Expand All @@ -72,7 +72,21 @@ func deserializebody(collationbody []byte) []body {

}

// Parse Collation body and modify it accordingly
func serialize(rawtx []blob) []byte {
length := int64(len(rawtx))
serialisedData := []byte{}

for i := int64(1); i < length; i++ {
data := rawtx[length].(txblob)
refinedData := data.serializeBlob()
serialisedData = append(serialisedData, refinedData...)
txblob(serialisedData).validateBody()

}
return serialisedData
}

// Parse blob and modify it accordingly

func (cb txblob) serializeBlob() []byte {

Expand Down

0 comments on commit c1ff070

Please sign in to comment.