(tos [][]byte, datas [][]byte)
| 1066 | } |
| 1067 | |
| 1068 | func (buf *Buffer) WriteCalls(tos [][]byte, datas [][]byte) (EncodeType, error) { |
| 1069 | if len(tos) == 0 { |
| 1070 | return Stateless, fmt.Errorf("calls are empty") |
| 1071 | } |
| 1072 | |
| 1073 | if len(tos) > 255 { |
| 1074 | return Stateless, fmt.Errorf("calls exceeds 255") |
| 1075 | } |
| 1076 | |
| 1077 | if len(tos) != len(datas) { |
| 1078 | return Stateless, fmt.Errorf("calls and datas have different lengths") |
| 1079 | } |
| 1080 | |
| 1081 | // The first byte is the number of calls |
| 1082 | buf.commitUint(uint(len(tos))) |
| 1083 | buf.end([]byte{}, Stateless) |
| 1084 | |
| 1085 | encodeType := Stateless |
| 1086 | |
| 1087 | for i, to := range tos { |
| 1088 | t, err := buf.WriteCall(to, datas[i]) |
| 1089 | if err != nil { |
| 1090 | return Stateless, err |
| 1091 | } |
| 1092 | |
| 1093 | encodeType = maxPriority(encodeType, t) |
| 1094 | } |
| 1095 | |
| 1096 | return encodeType, nil |
| 1097 | } |
no test coverage detected