MCPcopy Create free account
hub / github.com/copernet/copernicus / appendData

Function appendData

logic/lscript/lscript_test.go:84–103  ·  view source on GitHub ↗
(res, w []byte)

Source from the content-addressed store, hash-verified

82}
83
84func appendData(res, w []byte) []byte {
85 if len(w) < opcodes.OP_PUSHDATA1 {
86 res = append(res, byte(len(w)))
87 } else if len(w) <= 0xff {
88 res = append(res, []byte{opcodes.OP_PUSHDATA1, byte(len(w))}...)
89 } else if len(w) <= 0xffff {
90 res = append(res, opcodes.OP_PUSHDATA2)
91 buf := make([]byte, 2)
92 binary.LittleEndian.PutUint16(buf, uint16(len(w)))
93 res = append(res, buf...)
94 } else {
95 res = append(res, opcodes.OP_PUSHDATA4)
96 buf := make([]byte, 4)
97 binary.LittleEndian.PutUint32(buf, uint32(len(w)))
98 res = append(res, buf...)
99 }
100
101 res = append(res, w...)
102 return res
103}
104
105var scriptFlagMap = map[string]uint32{
106 "NONE": script.ScriptVerifyNone,

Callers 1

parseScriptFromFunction · 0.70

Calls 2

PutUint16Method · 0.80
PutUint32Method · 0.80

Tested by

no test coverage detected