MCPcopy Create free account
hub / github.com/akash-network/node / EncodeWithLengthPrefix

Function EncodeWithLengthPrefix

util/validation/address.go:39–45  ·  view source on GitHub ↗
(bz []byte)

Source from the content-addressed store, hash-verified

37}
38
39func EncodeWithLengthPrefix(bz []byte) ([]byte, error) {
40 if len(bz) > 255 {
41 return nil, fmt.Errorf("length-prefixed address too long")
42 }
43
44 return append([]byte{byte(len(bz))}, bz...), nil
45}
46
47func MustEncodeWithLengthPrefix(bz []byte) []byte {
48 res, err := EncodeWithLengthPrefix(bz)

Callers 3

ToPrefixMethod · 0.92
EncodeMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected