2014-10-31 08:30:08 -05:00
|
|
|
package xeth
|
2014-08-04 09:25:53 -05:00
|
|
|
|
2014-10-23 08:01:27 -05:00
|
|
|
import "github.com/ethereum/go-ethereum/ethutil"
|
2014-08-04 09:25:53 -05:00
|
|
|
|
|
|
|
var cnfCtr = ethutil.Hex2Bytes("661005d2720d855f1d9976f88bb10c1a3398c77f")
|
|
|
|
|
2014-08-05 04:31:39 -05:00
|
|
|
type Config struct {
|
2014-10-31 08:30:08 -05:00
|
|
|
pipe *XEth
|
2014-08-04 09:25:53 -05:00
|
|
|
}
|
|
|
|
|
2014-08-05 04:31:39 -05:00
|
|
|
func (self *Config) Get(name string) *Object {
|
2014-08-04 09:25:53 -05:00
|
|
|
configCtrl := self.pipe.World().safeGet(cnfCtr)
|
|
|
|
var addr []byte
|
|
|
|
|
|
|
|
switch name {
|
|
|
|
case "NameReg":
|
|
|
|
addr = []byte{0}
|
2014-08-07 08:26:07 -05:00
|
|
|
case "DnsReg":
|
2014-08-07 08:11:54 -05:00
|
|
|
objectAddr := configCtrl.GetStorage(ethutil.BigD([]byte{0}))
|
2014-08-07 08:26:07 -05:00
|
|
|
domainAddr := (&Object{self.pipe.World().safeGet(objectAddr.Bytes())}).StorageString("DnsReg").Bytes()
|
2014-08-07 08:11:54 -05:00
|
|
|
return &Object{self.pipe.World().safeGet(domainAddr)}
|
2014-11-07 05:18:48 -06:00
|
|
|
case "MergeMining":
|
|
|
|
addr = []byte{4}
|
2014-08-04 09:25:53 -05:00
|
|
|
default:
|
|
|
|
addr = ethutil.RightPadBytes([]byte(name), 32)
|
|
|
|
}
|
|
|
|
|
|
|
|
objectAddr := configCtrl.GetStorage(ethutil.BigD(addr))
|
2014-08-05 04:10:24 -05:00
|
|
|
|
2014-08-05 04:26:12 -05:00
|
|
|
return &Object{self.pipe.World().safeGet(objectAddr.Bytes())}
|
2014-08-04 09:25:53 -05:00
|
|
|
}
|
|
|
|
|
2014-08-05 04:31:39 -05:00
|
|
|
func (self *Config) Exist() bool {
|
2014-08-04 09:25:53 -05:00
|
|
|
return self.pipe.World().Get(cnfCtr) != nil
|
|
|
|
}
|