(data []byte)
| 59 | } |
| 60 | |
| 61 | func (self *ProgramBuilder) PushBytes(data []byte) *ProgramBuilder { |
| 62 | if len(data) == 0 { |
| 63 | panic("push data error: data is nil") |
| 64 | } |
| 65 | |
| 66 | if len(data) <= int(neovm.PUSHBYTES75)+1-int(neovm.PUSHBYTES1) { |
| 67 | self.sink.WriteByte(byte(len(data)) + byte(neovm.PUSHBYTES1) - 1) |
| 68 | } else if len(data) < 0x100 { |
| 69 | self.sink.WriteByte(byte(neovm.PUSHDATA1)) |
| 70 | self.sink.WriteUint8(uint8(len(data))) |
| 71 | } else if len(data) < 0x10000 { |
| 72 | self.sink.WriteByte(byte(neovm.PUSHDATA2)) |
| 73 | self.sink.WriteUint16(uint16(len(data))) |
| 74 | } else { |
| 75 | self.sink.WriteByte(byte(neovm.PUSHDATA4)) |
| 76 | self.sink.WriteUint32(uint32(len(data))) |
| 77 | } |
| 78 | self.sink.WriteBytes(data) |
| 79 | |
| 80 | return self |
| 81 | } |
| 82 | |
| 83 | func (self *ProgramBuilder) Finish() []byte { |
| 84 | return self.sink.Bytes() |
no test coverage detected