input byte array should be the following format version(1byte) + type(1byte) + data...
(input []byte)
| 51 | //input byte array should be the following format |
| 52 | // version(1byte) + type(1byte) + data... |
| 53 | func 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 |
| 80 | func EncodeValue(value interface{}) ([]byte, error) { |
nothing calls this directly
no test coverage detected