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

Method ReadSample

ethstorage/blobs/blob_reader.go:55–69  ·  view source on GitHub ↗
(shardIdx, sampleIdx uint64)

Source from the content-addressed store, hash-verified

53}
54
55func (n *BlobReader) ReadSample(shardIdx, sampleIdx uint64) (common.Hash, error) {
56 sampleLenBits := n.sm.MaxKvSizeBits() - es.SampleSizeBits
57 kvIdx := sampleIdx >> sampleLenBits
58 sampleIdxInKv := sampleIdx % (1 << sampleLenBits)
59
60 if sample := n.cr.GetSampleData(kvIdx, sampleIdxInKv); sample != nil {
61 return common.BytesToHash(sample), nil
62 }
63
64 sample, err := n.sm.ReadSampleUnlocked(shardIdx, sampleIdx)
65 if err != nil {
66 return common.Hash{}, err
67 }
68 return sample, nil
69}

Callers

nothing calls this directly

Calls 3

ReadSampleUnlockedMethod · 0.80
GetSampleDataMethod · 0.65
MaxKvSizeBitsMethod · 0.45

Tested by

no test coverage detected