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

Method checkMeta

ethstorage/storage_manager.go:557–575  ·  view source on GitHub ↗
(kvIdx uint64)

Source from the content-addressed store, hash-verified

555}
556
557func (s *StorageManager) checkMeta(kvIdx uint64) (common.Hash, error) {
558 metaInContract, err := s.l1Source.GetKvMetas([]uint64{kvIdx}, rpc.FinalizedBlockNumber.Int64())
559 if err != nil {
560 return common.Hash{}, fmt.Errorf("failed to query KV meta: kvIndex=%d, %w", kvIdx, err)
561 }
562 if len(metaInContract) == 0 {
563 return common.Hash{}, fmt.Errorf("failed to query KV meta: kvIndex=%d, no meta found", kvIdx)
564 }
565 var commit common.Hash
566 copy(commit[:], metaInContract[0][32-HashSizeInContract:32])
567 metaLocal, success, err := s.shardManager.TryReadMeta(kvIdx)
568 if err != nil {
569 return common.Hash{}, fmt.Errorf("failed to read local meta: kvIndex=%d, %w", kvIdx, err)
570 }
571 if !success {
572 return common.Hash{}, fmt.Errorf("local meta not found: kvIndex=%d", kvIdx)
573 }
574 return commit, CompareCommits(commit.Bytes(), metaLocal)
575}
576
577// TryWriteWithMetaCheck will try to fetch blob and write into the local storage file.
578// Before fetching blob, it will compare the provided commit to the one in the contract and make sure the correct commit is used.

Callers 2

CheckMetaMethod · 0.95
TryWriteWithMetaCheckMethod · 0.95

Calls 3

CompareCommitsFunction · 0.85
GetKvMetasMethod · 0.65
TryReadMetaMethod · 0.65

Tested by

no test coverage detected