MCPcopy Create free account
hub / github.com/ethstorage/es-node / checkCommit

Function checkCommit

ethstorage/data_shard.go:334–357  ·  view source on GitHub ↗
(commit common.Hash, blobData []byte)

Source from the content-addressed store, hash-verified

332var EmptyBlobCommit = make([]byte, HashSizeInContract)
333
334func checkCommit(commit common.Hash, blobData []byte) error {
335 // commit is empty 0x00..00
336 if bytes.Equal(commit[0:HashSizeInContract], EmptyBlobCommit) {
337 // blob is empty 0x00...00
338 for _, b := range blobData {
339 if b != 0 {
340 return fmt.Errorf("empty commit but blob is not empty")
341 }
342 }
343 return nil
344 }
345
346 // kzg blob
347 blob := kzg4844.Blob{}
348 copy(blob[:], blobData)
349 // Generate VersionedHash
350 commitment, err := kzg4844.BlobToCommitment(&blob)
351 if err != nil {
352 return fmt.Errorf("could not convert blob to commitment: %v", err)
353 }
354 versionedHash := eth.KZGToVersionedHash(eth.KZGCommitment(commitment))
355 // Get the hash and only take 24 bits
356 return CompareCommits(commit.Bytes(), versionedHash[:])
357}
358
359// Write a value of the KV to the store using a customized encoder.
360func (ds *DataShard) WriteWith(kvIdx uint64, b []byte, commit common.Hash, encoder func([]byte, uint64) []byte) error {

Callers 2

ReadMethod · 0.85
ReadWithMetaMethod · 0.85

Calls 1

CompareCommitsFunction · 0.85

Tested by

no test coverage detected