sharding: comments

Former-commit-id: b29911129f820422182914d7f9ebb0fdd9c02b91 [formerly e3b08d27926b957c87b2dee7d15ae0b2c9159f82]
Former-commit-id: 29a6fc4bf4a8b351ba2e0b0175817e5ecaedec04
This commit is contained in:
Eli
2018-05-27 23:46:54 -07:00
parent 20e15edce9
commit e8224cd71a
3 changed files with 5 additions and 6 deletions

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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)