Added vm options for object execution

This commit is contained in:
obscuren
2014-08-05 11:10:24 +02:00
parent c215bbadf1
commit 4f0bda403e
4 changed files with 58 additions and 39 deletions

View File

@@ -1,33 +1,14 @@
package ethpipe
import (
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
)
import "github.com/ethereum/eth-go/ethutil"
var cnfCtr = ethutil.Hex2Bytes("661005d2720d855f1d9976f88bb10c1a3398c77f")
type object struct {
*ethstate.StateObject
}
func (self object) StorageString(str string) *ethutil.Value {
if ethutil.IsHex(str) {
return self.Storage(ethutil.Hex2Bytes(str[2:]))
} else {
return self.Storage(ethutil.RightPadBytes([]byte(str), 32))
}
}
func (self object) Storage(addr []byte) *ethutil.Value {
return self.StateObject.GetStorage(ethutil.BigD(addr))
}
type config struct {
pipe *Pipe
}
func (self *config) Get(name string) object {
func (self *config) Get(name string) *object {
configCtrl := self.pipe.World().safeGet(cnfCtr)
var addr []byte
@@ -39,7 +20,8 @@ func (self *config) Get(name string) object {
}
objectAddr := configCtrl.GetStorage(ethutil.BigD(addr))
return object{self.pipe.World().safeGet(objectAddr.Bytes())}
return &object{self.pipe.World().safeGet(objectAddr.Bytes())}
}
func (self *config) Exist() bool {