MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BlockAt

Method BlockAt

internal/utils/bfs/file_header.go:25–44  ·  view source on GitHub ↗
(offset int64)

Source from the content-addressed store, hash-verified

23}
24
25func (this *FileHeader) BlockAt(offset int64) (blockInfo BlockInfo, ok bool) {
26 var l = len(this.BodyBlocks)
27 if l == 1 {
28 if this.BodyBlocks[0].Contains(offset) {
29 return this.BodyBlocks[0], true
30 }
31 return
32 }
33
34 sort.Search(l, func(i int) bool {
35 if this.BodyBlocks[i].Contains(offset) {
36 blockInfo = this.BodyBlocks[i]
37 ok = true
38 return true
39 }
40 return this.BodyBlocks[i].OriginOffsetFrom > offset
41 })
42
43 return
44}
45
46func (this *FileHeader) MaxOffset() int64 {
47 var l = len(this.BodyBlocks)

Callers 1

ReadAtMethod · 0.80

Calls 1

ContainsMethod · 0.45

Tested by

no test coverage detected