MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / DecodeMetaBlock

Function DecodeMetaBlock

internal/utils/bfs/meta_block.go:33–52  ·  view source on GitHub ↗
(blockBytes []byte)

Source from the content-addressed store, hash-verified

31}
32
33func DecodeMetaBlock(blockBytes []byte) (action MetaAction, hash string, data []byte, err error) {
34 var dataOffset = 4 /** Len **/ + HashLen + 1 /** Action **/
35 if len(blockBytes) < dataOffset {
36 err = errors.New("decode failed: invalid block data")
37 return
38 }
39
40 action = blockBytes[4]
41 hash = string(blockBytes[5 : 5+HashLen])
42
43 if action == MetaActionNew {
44 var rawData = blockBytes[dataOffset:]
45 if len(rawData) > 0 {
46 data = make([]byte, len(rawData))
47 copy(data, rawData)
48 }
49 }
50
51 return
52}

Callers 5

TestMetaBlockFunction · 0.92
TestFileHeader_EncodeFunction · 0.92
loadMethod · 0.85

Calls

no outgoing calls

Tested by 4

TestMetaBlockFunction · 0.74
TestFileHeader_EncodeFunction · 0.74