(kvIdx uint64)
| 555 | } |
| 556 | |
| 557 | func (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. |
no test coverage detected