(kvIndex uint64, blobHash common.Hash, decodeType DecodeType, off, size uint64)
| 40 | } |
| 41 | |
| 42 | func (api *esAPI) GetBlob(kvIndex uint64, blobHash common.Hash, decodeType DecodeType, off, size uint64) (hexutil.Bytes, error) { |
| 43 | blob := api.dl.Cache.GetKeyValueByIndex(kvIndex, blobHash) |
| 44 | |
| 45 | if blob == nil { |
| 46 | commit, _, err := api.sm.TryReadMeta(kvIndex) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | |
| 51 | if err := ethstorage.CompareCommits(blobHash.Bytes(), commit); err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | |
| 55 | readCommit := common.Hash{} |
| 56 | copy(readCommit[0:ethstorage.HashSizeInContract], blobHash[0:ethstorage.HashSizeInContract]) |
| 57 | |
| 58 | var found bool |
| 59 | blob, found, err = api.sm.TryRead(kvIndex, int(api.sm.MaxKvSize()), readCommit) |
| 60 | if err != nil { |
| 61 | return nil, err |
| 62 | } |
| 63 | if !found { |
| 64 | return nil, ethereum.NotFound |
| 65 | } |
| 66 | } else { |
| 67 | blob = api.sm.DecodeBlob(blob, blobHash, kvIndex, api.sm.MaxKvSize()) |
| 68 | } |
| 69 | |
| 70 | ret := blob |
| 71 | |
| 72 | if decodeType == PaddingPer31Bytes { |
| 73 | ret = utils.DecodeBlob(blob) |
| 74 | } else if decodeType == OptimismCompact { |
| 75 | var err error |
| 76 | if ret, err = utils.ToData(blob); err != nil { |
| 77 | return nil, err |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if len(ret) < int(off+size) { |
| 82 | return nil, errors.New("beyond the range of blob size") |
| 83 | } |
| 84 | |
| 85 | return ret[off : off+size], nil |
| 86 | } |
nothing calls this directly
no test coverage detected