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

Method GetBlob

ethstorage/blobs/blob_reader.go:37–53  ·  view source on GitHub ↗
(kvIdx uint64, kvHash common.Hash)

Source from the content-addressed store, hash-verified

35}
36
37func (n *BlobReader) GetBlob(kvIdx uint64, kvHash common.Hash) ([]byte, error) {
38 if blob := n.cr.GetKeyValueByIndex(kvIdx, kvHash); blob != nil {
39 n.lg.Debug("Loaded blob from downloader cache", "kvIdx", kvIdx)
40 blobDecoded := n.sm.DecodeBlob(blob, kvHash, kvIdx, n.sm.MaxKvSize())
41 return blobDecoded, nil
42 }
43
44 blob, exist, err := n.sm.TryRead(kvIdx, int(n.sm.MaxKvSize()), kvHash)
45 if err != nil {
46 return nil, err
47 }
48 if !exist {
49 return nil, fmt.Errorf("kv not found: index=%d", kvIdx)
50 }
51 n.lg.Debug("Loaded blob from storage manager", "kvIdx", kvIdx)
52 return blob, nil
53}
54
55func (n *BlobReader) ReadSample(shardIdx, sampleIdx uint64) (common.Hash, error) {
56 sampleLenBits := n.sm.MaxKvSizeBits() - es.SampleSizeBits

Callers

nothing calls this directly

Calls 4

DecodeBlobMethod · 0.80
GetKeyValueByIndexMethod · 0.65
MaxKvSizeMethod · 0.65
TryReadMethod · 0.65

Tested by

no test coverage detected