aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/sqlvm/sqlvm.go
blob: 26aeeab0bca6221f25c417a0bd39473fdb0f132e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package sqlvm

import (
    "math/big"

    "github.com/dexon-foundation/dexon/common"
    "github.com/dexon-foundation/dexon/core/vm"
    "github.com/dexon-foundation/dexon/params"
)

// SQLVM implements the required VM interface.
type SQLVM struct {
    // Context provides auxiliary blockchain related information
    *vm.Context
    // StateDB gives access to the underlying state
    StateDB vm.StateDB

    // abort is used to abort the SQLVM calling operations
    // NOTE: must be set atomically
    abort int32
}

func init() {
    vm.Register(vm.SQLVM, NewSQLVM)
}

// NewSQLVM is the SQLVM constructor.
func NewSQLVM(context *vm.Context, stateDB vm.StateDB, chainConfig *params.ChainConfig, vmConfig interface{}) vm.VM {
    return &SQLVM{Context: context, StateDB: stateDB}
}

// Create creates SQL contract.
func (sqlvm *SQLVM) Create(caller vm.ContractRef, code []byte, gas uint64, value *big.Int,
    pack *vm.ExecPack) ([]byte, common.Address, uint64, error) {
    // todo (jm) need to implemnt
    return nil, common.Address{}, gas, nil
}

// Create2 mock interface.
func (sqlvm *SQLVM) Create2(caller vm.ContractRef, code []byte, gas uint64, endowment *big.Int, salt *big.Int,
    pack *vm.ExecPack) ([]byte, common.Address, uint64, error) {
    // todo (jm) need to implemnt
    return nil, common.Address{}, gas, nil
}

// Call is the entry to call SQLVM contract.
func (sqlvm *SQLVM) Call(caller vm.ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int,
    pack *vm.ExecPack) ([]byte, uint64, error) {
    // todo (jm) need to implemnt
    return nil, gas, nil
}

// CallCode mock interface.
func (sqlvm *SQLVM) CallCode(caller vm.ContractRef, addr common.Address, input []byte, gas uint64,
    value *big.Int, pack *vm.ExecPack) ([]byte, uint64, error) {
    // todo (jm) need to implemnt
    return nil, gas, nil
}

// DelegateCall mock interface.
func (sqlvm *SQLVM) DelegateCall(caller vm.ContractRef, addr common.Address, input []byte, gas uint64,
    pack *vm.ExecPack) ([]byte, uint64, error) {
    // todo (jm) need to implemnt
    return nil, gas, nil
}

// StaticCall is the entry for read-only call on SQL contract.
func (sqlvm *SQLVM) StaticCall(caller vm.ContractRef, addr common.Address, input []byte, gas uint64,
    pack *vm.ExecPack) ([]byte, uint64, error) {
    // todo (jm) need to implemnt
    return nil, gas, nil
}