Bytes encodes the Block as a byte slice, by converting it to a RawBlock protobuf and marshaling that.
()
| 168 | // Bytes encodes the Block as a byte slice, by converting it to a |
| 169 | // RawBlock protobuf and marshaling that. |
| 170 | func (b *Block) Bytes() ([]byte, error) { |
| 171 | var txs []*RawTx |
| 172 | for _, tx := range b.Transactions { |
| 173 | txs = append(txs, &RawTx{ |
| 174 | Version: tx.Version, |
| 175 | Runlimit: tx.Runlimit, |
| 176 | Program: tx.Program, |
| 177 | }) |
| 178 | } |
| 179 | var args []*DataItem |
| 180 | for _, arg := range b.Arguments { |
| 181 | switch a := arg.(type) { |
| 182 | case []byte: |
| 183 | args = append(args, &DataItem{Type: DataType_BYTES, Bytes: a}) |
| 184 | case int64: |
| 185 | args = append(args, &DataItem{Type: DataType_INT, Int: a}) |
| 186 | case []*DataItem: |
| 187 | args = append(args, &DataItem{Type: DataType_TUPLE, Tuple: a}) |
| 188 | } |
| 189 | } |
| 190 | rb := &RawBlock{ |
| 191 | Header: b.BlockHeader, |
| 192 | Transactions: txs, |
| 193 | Arguments: args, |
| 194 | } |
| 195 | return proto.Marshal(rb) |
| 196 | } |
no outgoing calls
no test coverage detected