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

Method PushBytes

core/program/program.go:61–81  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

59}
60
61func (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
83func (self *ProgramBuilder) Finish() []byte {
84 return self.sink.Bytes()

Callers 15

PushPubKeyMethod · 0.95
PushNumMethod · 0.95
ProgramFromParamsFunction · 0.95
EncodeParamProgramIntoFunction · 0.95
ContractGetCodeFunction · 0.45
StorageGetFunction · 0.45
HeaderGetHashFunction · 0.45
HeaderGetPrevHashFunction · 0.45
HeaderGetMerkleRootFunction · 0.45
HeaderGetNextConsensusFunction · 0.45
NativeInvokeFunction · 0.45

Calls 5

WriteByteMethod · 0.80
WriteUint8Method · 0.80
WriteUint16Method · 0.80
WriteUint32Method · 0.80
WriteBytesMethod · 0.80

Tested by

no test coverage detected