aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-04 17:53:49 +0800
committerobscuren <geffobscura@gmail.com>2014-12-04 17:53:49 +0800
commit83663ed4b01480c628ce2c849e4e881ac04b5120 (patch)
tree0bbef8acd355038c39b754aeb3d615e47257686e /xeth
parent9008b155d3c8d2a32c4c8945f1174243d48d4e90 (diff)
downloadgo-tangerine-83663ed4b01480c628ce2c849e4e881ac04b5120.tar.gz
go-tangerine-83663ed4b01480c628ce2c849e4e881ac04b5120.tar.zst
go-tangerine-83663ed4b01480c628ce2c849e4e881ac04b5120.zip
Renames for chain, updated VM, moved methods
* Renamed a couple more chain => core * Updated VM `pc` to be uint64 rather than big int * XEth interface cleanup
Diffstat (limited to 'xeth')
-rw-r--r--xeth/pipe.go63
1 files changed, 28 insertions, 35 deletions
diff --git a/xeth/pipe.go b/xeth/pipe.go
index cabcc1cbe..f1ecd19d5 100644
--- a/xeth/pipe.go
+++ b/xeth/pipe.go
@@ -39,6 +39,9 @@ func New(obj core.EthManager) *XEth {
return pipe
}
+/*
+ * State / Account accessors
+ */
func (self *XEth) Balance(addr []byte) *ethutil.Value {
return ethutil.NewValue(self.World().safeGet(addr).Balance)
}
@@ -47,32 +50,6 @@ func (self *XEth) Nonce(addr []byte) uint64 {
return self.World().safeGet(addr).Nonce
}
-func (self *XEth) Execute(addr []byte, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
- return self.ExecuteObject(&Object{self.World().safeGet(addr)}, data, value, gas, price)
-}
-
-func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
- var (
- initiator = state.NewStateObject(self.obj.KeyManager().KeyPair().Address())
- block = self.blockChain.CurrentBlock
- )
-
- self.Vm.State = self.World().State().Copy()
-
- vmenv := NewEnv(self.Vm.State, block, value.BigInt(), initiator.Address())
- return vmenv.Call(initiator, object.Address(), data, gas.BigInt(), price.BigInt(), value.BigInt())
- /*
- evm := vm.New(, vm.Type(ethutil.Config.VmType))
-
- msg := vm.NewExecution(evm, object.Address(), data, gas.BigInt(), price.BigInt(), value.BigInt())
- ret, err := msg.Exec(object.Address(), initiator)
-
- fmt.Println("returned from call", ret, err)
-
- return ret, err
- */
-}
-
func (self *XEth) Block(hash []byte) *types.Block {
return self.blockChain.GetBlock(hash)
}
@@ -81,6 +58,11 @@ func (self *XEth) Storage(addr, storageAddr []byte) *ethutil.Value {
return self.World().safeGet(addr).GetStorage(ethutil.BigD(storageAddr))
}
+func (self *XEth) Exists(addr []byte) bool {
+ return self.World().Get(addr) != nil
+}
+
+// Converts the given private key to an address
func (self *XEth) ToAddress(priv []byte) []byte {
pair, err := crypto.NewKeyPairFromSec(priv)
if err != nil {
@@ -90,10 +72,28 @@ func (self *XEth) ToAddress(priv []byte) []byte {
return pair.Address()
}
-func (self *XEth) Exists(addr []byte) bool {
- return self.World().Get(addr) != nil
+/*
+ * Execution helpers
+ */
+func (self *XEth) Execute(addr []byte, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
+ return self.ExecuteObject(&Object{self.World().safeGet(addr)}, data, value, gas, price)
+}
+
+func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
+ var (
+ initiator = state.NewStateObject(self.obj.KeyManager().KeyPair().Address())
+ block = self.blockChain.CurrentBlock
+ )
+
+ self.Vm.State = self.World().State().Copy()
+
+ vmenv := NewEnv(self.Vm.State, block, value.BigInt(), initiator.Address())
+ return vmenv.Call(initiator, object.Address(), data, gas.BigInt(), price.BigInt(), value.BigInt())
}
+/*
+ * Transactional methods
+ */
func (self *XEth) TransactString(key *crypto.KeyPair, rec string, value, gas, price *ethutil.Value, data []byte) (*types.Transaction, error) {
// Check if an address is stored by this address
var hash []byte
@@ -149,13 +149,6 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et
}
return tx, nil
-
- //acc := self.blockManager.TransState().GetOrNewStateObject(key.Address())
- //self.obj.TxPool().QueueTransaction(tx)
-
- //acc.Nonce += 1
- //self.blockManager.TransState().UpdateStateObject(acc)
-
}
func (self *XEth) PushTx(tx *types.Transaction) ([]byte, error) {