aboutsummaryrefslogtreecommitdiffstats
path: root/common/resolver
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-04-06 14:01:36 +0800
committerzelig <viktor.tron@gmail.com>2015-04-20 03:57:49 +0800
commit94489b2269133c545aa3e9580737b2bd93f3ead0 (patch)
treebd486d5c4c432763dbc356f5f6ea79768f186603 /common/resolver
parente2d333d2095edb349388433c28f4d6a381b1df62 (diff)
downloadgo-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.tar
go-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.tar.gz
go-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.tar.bz2
go-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.tar.lz
go-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.tar.xz
go-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.tar.zst
go-tangerine-94489b2269133c545aa3e9580737b2bd93f3ead0.zip
s
Diffstat (limited to 'common/resolver')
-rw-r--r--common/resolver/resolver.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/resolver/resolver.go b/common/resolver/resolver.go
index 1d80fdb42..060e9dbb5 100644
--- a/common/resolver/resolver.go
+++ b/common/resolver/resolver.go
@@ -39,7 +39,7 @@ func New(eth Backend, uhca, nrca string) *Resolver {
func (self *Resolver) NameToContentHash(name string) (chash common.Hash, err error) {
// look up in nameReg
key := storageAddress(1, common.Hex2BytesFixed(name, 32))
- hash := self.backend.StorageAt(self.nameRegContractAddress, key)
+ hash := self.backend.StorageAt("0x"+self.nameRegContractAddress, key)
copy(chash[:], common.Hex2Bytes(hash))
return
}
@@ -47,7 +47,8 @@ func (self *Resolver) NameToContentHash(name string) (chash common.Hash, err err
func (self *Resolver) ContentHashToUrl(chash common.Hash) (uri string, err error) {
// look up in nameReg
key := storageAddress(2, chash[:])
- uri = string(common.Hex2Bytes(self.backend.StorageAt(self.urlHintContractAddress, key)))
+ hex := self.backend.StorageAt("0x"+self.urlHintContractAddress, key)
+ uri = string(common.Hex2Bytes(hex[2:]))
l := len(uri)
for (l > 0) && (uri[l-1] == 0) {
l--
@@ -72,7 +73,7 @@ func (self *Resolver) NameToUrl(name string) (uri string, hash common.Hash, err
func storageAddress(varidx uint32, key []byte) string {
data := make([]byte, 64)
- binary.BigEndian.PutUint32(data[28:32], varidx)
- copy(data[32:64], key[0:32])
- return common.Bytes2Hex(crypto.Sha3(data))
+ binary.BigEndian.PutUint32(data[60:64], varidx)
+ copy(data[0:32], key[0:32])
+ return "0x" + common.Bytes2Hex(crypto.Sha3(data))
}