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

Method ReadBytes

core/program/program.go:212–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210}
211
212func (self *programParser) ReadBytes() ([]byte, error) {
213 code, err := self.ReadOpCode()
214 if err != nil {
215 return nil, err
216 }
217
218 var keylen uint64
219 var eof bool
220 if code == neovm.PUSHDATA4 {
221 var temp uint32
222 temp, eof = self.source.NextUint32()
223 keylen = uint64(temp)
224 } else if code == neovm.PUSHDATA2 {
225 var temp uint16
226 temp, eof = self.source.NextUint16()
227 keylen = uint64(temp)
228 } else if code == neovm.PUSHDATA1 {
229 var temp uint8
230 temp, eof = self.source.NextUint8()
231 keylen = uint64(temp)
232 } else if byte(code) <= byte(neovm.PUSHBYTES75) && byte(code) >= byte(neovm.PUSHBYTES1) {
233 keylen = uint64(code) - uint64(neovm.PUSHBYTES1) + 1
234 } else {
235 err = fmt.Errorf("unexpected opcode: %d", byte(code))
236 }
237 if eof {
238 err = io.ErrUnexpectedEOF
239 }
240 if err != nil {
241 return nil, err
242 }
243
244 buf, eof := self.source.NextBytes(keylen)
245 if eof {
246 return nil, io.ErrUnexpectedEOF
247 }
248
249 return buf, err
250}
251
252func (self *programParser) ReadPubKey() (keypair.PublicKey, error) {
253 buf, err := self.ReadBytes()

Callers 4

ReadNumMethod · 0.95
ReadPubKeyMethod · 0.95
GetProgramInfoFunction · 0.95
GetParamInfoFunction · 0.95

Calls 6

ReadOpCodeMethod · 0.95
NextUint32Method · 0.80
NextUint16Method · 0.80
NextUint8Method · 0.80
ErrorfMethod · 0.80
NextBytesMethod · 0.45

Tested by

no test coverage detected