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

Method CommitBlob

ethstorage/storage_manager.go:305–325  ·  view source on GitHub ↗

CommitBlob This function will be called when p2p sync received a blob. Return err if the passed commit and the one queried from contract are not matched.

(kvIndex uint64, blob []byte, commit common.Hash)

Source from the content-addressed store, hash-verified

303// CommitBlob This function will be called when p2p sync received a blob.
304// Return err if the passed commit and the one queried from contract are not matched.
305func (s *StorageManager) CommitBlob(kvIndex uint64, blob []byte, commit common.Hash) error {
306 encodedBlob, success, err := s.shardManager.TryEncodeKV(kvIndex, blob, commit)
307 if !success || err != nil {
308 return errors.New("blob encode failed")
309 }
310
311 s.mu.Lock()
312 defer s.mu.Unlock()
313
314 metas, err := s.getKvMetas([]uint64{kvIndex})
315 if err != nil {
316 return err
317 }
318
319 if len(metas) != 1 {
320 return errors.New("invalid params lens")
321 }
322
323 contractMeta := metas[0]
324 return s.commitEncodedBlob(kvIndex, encodedBlob, commit, contractMeta)
325}
326
327func (s *StorageManager) commitEncodedBlob(kvIndex uint64, encodedBlob []byte, commit common.Hash, contractMeta [32]byte) error {
328 // the commit is different with what we got from the contract, so should not commit

Callers

nothing calls this directly

Calls 3

getKvMetasMethod · 0.95
commitEncodedBlobMethod · 0.95
TryEncodeKVMethod · 0.80

Tested by

no test coverage detected