forked from TrueCloudLab/neoneo-go
native: add GetOracleInvokeScript()
This commit is contained in:
parent
d50a14359a
commit
17922038dc
1 changed files with 14 additions and 3 deletions
|
@ -46,15 +46,19 @@ const (
|
||||||
oracleRequestPrice = 5000_0000
|
oracleRequestPrice = 5000_0000
|
||||||
)
|
)
|
||||||
|
|
||||||
var oracleScript []byte
|
var (
|
||||||
|
oracleInvokeScript []byte
|
||||||
|
oracleScript []byte
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
emit.String(w.BinWriter, oracleName)
|
emit.String(w.BinWriter, oracleName)
|
||||||
emit.Syscall(w.BinWriter, interopnames.NeoNativeCall)
|
emit.Syscall(w.BinWriter, interopnames.NeoNativeCall)
|
||||||
h := hash.Hash160(w.Bytes())
|
oracleInvokeScript = w.Bytes()
|
||||||
|
h := hash.Hash160(oracleInvokeScript)
|
||||||
|
|
||||||
w.Reset()
|
w = io.NewBufBinWriter()
|
||||||
emit.Int(w.BinWriter, 0)
|
emit.Int(w.BinWriter, 0)
|
||||||
emit.Opcodes(w.BinWriter, opcode.NEWARRAY)
|
emit.Opcodes(w.BinWriter, opcode.NEWARRAY)
|
||||||
emit.String(w.BinWriter, "finish")
|
emit.String(w.BinWriter, "finish")
|
||||||
|
@ -79,6 +83,13 @@ var (
|
||||||
ErrResponseNotFound = errors.New("oracle response not found")
|
ErrResponseNotFound = errors.New("oracle response not found")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetOracleInvokeScript returns oracle contract script.
|
||||||
|
func GetOracleInvokeScript() []byte {
|
||||||
|
b := make([]byte, len(oracleInvokeScript))
|
||||||
|
copy(b, oracleInvokeScript)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
// GetOracleResponseScript returns script for transaction with oracle response.
|
// GetOracleResponseScript returns script for transaction with oracle response.
|
||||||
func GetOracleResponseScript() []byte {
|
func GetOracleResponseScript() []byte {
|
||||||
b := make([]byte, len(oracleScript))
|
b := make([]byte, len(oracleScript))
|
||||||
|
|
Loading…
Reference in a new issue