diff --git a/sharding/collation.go b/sharding/collation.go index 9d9aed0292..8c110de16f 100644 --- a/sharding/collation.go +++ b/sharding/collation.go @@ -107,7 +107,7 @@ func (c *Collation) CalculateChunkRoot() { // TODO: For proof of custody we need to split chunks (body) into chunk + salt // and take the merkle root of that. - chunks := Chunks(c.body) // wrapper allowing us to merklizing the chunks + chunks := Chunks(c.body) // wrapper allowing us to merklizing the chunks. chunkRoot := types.DeriveSha(chunks) // merklize the serialized blobs. c.header.data.ChunkRoot = &chunkRoot } diff --git a/sharding/shard.go b/sharding/shard.go index b5bc54f712..b3c896fe22 100644 --- a/sharding/shard.go +++ b/sharding/shard.go @@ -70,8 +70,7 @@ func (s *Shard) CollationByHash(headerHash *common.Hash) (*Collation, error) { return nil, fmt.Errorf("cannot fetch body by chunk root: %v", err) } - // deserialize the body into a txs slice instead of using - // nil as the third arg to MakeCollation. + // deserialize the body into a txs slice. txs, err := DeserializeBlobToTx(body) if err != nil { return nil, fmt.Errorf("cannot deserialize body: %v", err) @@ -173,11 +172,11 @@ func (s *Shard) SaveHeader(header *CollationHeader) error { // SaveBody adds the collation body to the shardDB and sets availability. func (s *Shard) SaveBody(body []byte) error { // check if body is empty and throw error. - if body == nil || len(body) == 0 { // is this check strict enough? + if body == nil || len(body) == 0 { return fmt.Errorf("body is empty") } - chunks := Chunks(body) // wrapper allowing us to merklizing the chunks + chunks := Chunks(body) // wrapper allowing us to merklizing the chunks. chunkRoot := types.DeriveSha(chunks) // merklize the serialized blobs. s.SetAvailability(&chunkRoot, true) return s.shardDB.Put(chunkRoot.Bytes(), body) diff --git a/sharding/shard_test.go b/sharding/shard_test.go index e99d996238..f4b1b55ac3 100644 --- a/sharding/shard_test.go +++ b/sharding/shard_test.go @@ -275,7 +275,7 @@ func TestShard_BodyByChunkRoot(t *testing.T) { t.Fatalf("cannot save body: %v", err) } - chunks := Chunks(body) // wrapper allowing us to merklizing the chunks + chunks := Chunks(body) // wrapper allowing us to merklizing the chunks. chunkRoot := types.DeriveSha(chunks) // merklize the serialized blobs. dbBody, err := shard.BodyByChunkRoot(&chunkRoot)