MCPcopy Create free account
hub / github.com/DNAProject/DNA / DeserializeInput

Function DeserializeInput

vm/crossvm_codec/codec.go:53–77  ·  view source on GitHub ↗

input byte array should be the following format version(1byte) + type(1byte) + data...

(input []byte)

Source from the content-addressed store, hash-verified

51//input byte array should be the following format
52// version(1byte) + type(1byte) + data...
53func DeserializeInput(input []byte) ([]interface{}, error) {
54 if len(input) == 0 {
55 return nil, ERROR_PARAM_FORMAT
56 }
57 if len(input) > MAX_PARAM_LENGTH {
58 return nil, ERROR_PARAM_TOO_LONG
59 }
60 version := input[0]
61 //current only support "0" version
62 if version != VERSION {
63 return nil, ERROR_PARAM_FORMAT
64 }
65
66 paramlist := make([]interface{}, 0)
67 source := common.NewZeroCopySource(input[1:])
68 for source.Len() != 0 {
69 val, err := DecodeValue(source)
70 if err != nil {
71 return nil, err
72 }
73 paramlist = append(paramlist, val)
74 }
75
76 return paramlist, nil
77}
78
79// currently only used by test case
80func EncodeValue(value interface{}) ([]byte, error) {

Callers

nothing calls this directly

Calls 3

LenMethod · 0.95
NewZeroCopySourceFunction · 0.92
DecodeValueFunction · 0.85

Tested by

no test coverage detected