diff options
author | JM <jm@dexon.org> | 2019-01-31 15:12:57 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-03-26 17:48:21 +0800 |
commit | 1ea57eed7e9e37b40d27b11fe316cfe3569fade6 (patch) | |
tree | 9f5b919f6c75e6dd713902ecc96a0c845679649a /core/vm/sqlvm | |
parent | 1810c3af03d3da56d42f93c4521e33332156dcb6 (diff) | |
download | dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.tar dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.tar.gz dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.tar.bz2 dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.tar.lz dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.tar.xz dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.tar.zst dexon-1ea57eed7e9e37b40d27b11fe316cfe3569fade6.zip |
core: vm: vm interface (#164)
Diffstat (limited to 'core/vm/sqlvm')
-rw-r--r-- | core/vm/sqlvm/sqlvm.go | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/core/vm/sqlvm/sqlvm.go b/core/vm/sqlvm/sqlvm.go index 258a65d01..fe2eee42b 100644 --- a/core/vm/sqlvm/sqlvm.go +++ b/core/vm/sqlvm/sqlvm.go @@ -5,7 +5,6 @@ import ( "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/vm" - "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/params" ) @@ -30,21 +29,39 @@ type SQLVM struct { callGasTemp uint64 } -func (sqlvm *SQLVM) Create(caller vm.ContractRef, code []byte, gas uint64, - value *big.Int) (ret []byte, contractAddr common.Address, - leftOverGas uint64, err error) { +func init() { + vm.Register(vm.SQLVM, &SQLVM{}) +} - contractAddr = crypto.CreateAddress(caller.Address(), sqlvm.StateDB.GetNonce(caller.Address())) - return sqlvm.create(caller, &vm.CodeAndHash{Code: code}, gas, value, contractAddr) +func (sqlvm *SQLVM) Create(caller vm.ContractRef, code []byte, gas uint64, value *big.Int, + in vm.Interpreter) ([]byte, common.Address, uint64, error) { + // todo (jm) need to implemnt + return nil, common.Address{}, gas, nil } -// create creates a new contract using code as deployment code. -func (sqlvm *SQLVM) create(caller vm.ContractRef, codeAndHash *vm.CodeAndHash, gas uint64, - value *big.Int, address common.Address) ([]byte, common.Address, uint64, error) { - // Depth check execution. Fail if we're trying to execute above the - if sqlvm.depth > int(params.CallCreateDepth) { - return nil, common.Address{}, gas, vm.ErrDepth - } - // TODO (JM) implement create database contract function +func (sqlvm *SQLVM) Create2(caller vm.ContractRef, code []byte, gas uint64, endowment *big.Int, salt *big.Int, + in vm.Interpreter) ([]byte, common.Address, uint64, error) { + // todo (jm) need to implemnt return nil, common.Address{}, gas, nil } +func (sqlvm *SQLVM) Call(caller vm.ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int, + in vm.Interpreter) ([]byte, uint64, error) { + // todo (jm) need to implemnt + return nil, gas, nil +} +func (sqlvm *SQLVM) CallCode(caller vm.ContractRef, addr common.Address, input []byte, gas uint64, + value *big.Int, in vm.Interpreter) ([]byte, uint64, error) { + // todo (jm) need to implemnt + return nil, gas, nil +} + +func (sqlvm *SQLVM) DelegateCall(caller vm.ContractRef, addr common.Address, input []byte, gas uint64, + in vm.Interpreter) ([]byte, uint64, error) { + // todo (jm) need to implemnt + return nil, gas, nil +} +func (sqlvm *SQLVM) StaticCall(caller vm.ContractRef, addr common.Address, input []byte, gas uint64, + in vm.Interpreter) ([]byte, uint64, error) { + // todo (jm) need to implemnt + return nil, gas, nil +} |