2014-08-04 14:25:53 +00:00
|
|
|
package ethpipe
|
|
|
|
|
2014-08-05 09:10:24 +00:00
|
|
|
import "github.com/ethereum/eth-go/ethutil"
|
2014-08-04 14:25:53 +00:00
|
|
|
|
|
|
|
var cnfCtr = ethutil.Hex2Bytes("661005d2720d855f1d9976f88bb10c1a3398c77f")
|
|
|
|
|
|
|
|
type config struct {
|
|
|
|
pipe *Pipe
|
|
|
|
}
|
|
|
|
|
2014-08-05 09:26:12 +00:00
|
|
|
func (self *config) Get(name string) *Object {
|
2014-08-04 14:25:53 +00:00
|
|
|
configCtrl := self.pipe.World().safeGet(cnfCtr)
|
|
|
|
var addr []byte
|
|
|
|
|
|
|
|
switch name {
|
|
|
|
case "NameReg":
|
|
|
|
addr = []byte{0}
|
|
|
|
default:
|
|
|
|
addr = ethutil.RightPadBytes([]byte(name), 32)
|
|
|
|
}
|
|
|
|
|
|
|
|
objectAddr := configCtrl.GetStorage(ethutil.BigD(addr))
|
2014-08-05 09:10:24 +00:00
|
|
|
|
2014-08-05 09:26:12 +00:00
|
|
|
return &Object{self.pipe.World().safeGet(objectAddr.Bytes())}
|
2014-08-04 14:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *config) Exist() bool {
|
|
|
|
return self.pipe.World().Get(cnfCtr) != nil
|
|
|
|
}
|