aboutsummaryrefslogtreecommitdiffstats
path: root/common/natspec/natspec.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-06-23 22:48:33 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 16:43:31 +0800
commit83ee39448e0f23d42dff27bccde27f828afa3707 (patch)
tree429fa8f20a4bc017a58ffc4c7c0ed8596d1d206f /common/natspec/natspec.go
parentd764bd058457cd9eb91d205d1ac187d40c4866d6 (diff)
downloadgo-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.tar
go-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.tar.gz
go-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.tar.bz2
go-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.tar.lz
go-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.tar.xz
go-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.tar.zst
go-tangerine-83ee39448e0f23d42dff27bccde27f828afa3707.zip
Registrar and contractInfo handling
* resolver -> common/registrar * global registrar name registry interface * add Call to resolver backend interface * the hashReg and UrlHing contracts now initialised from global registry * initialization of contracts uniform * improve errors and more econsistent method names * common/registrar/ethreg: versioned registrar * integrate new naming and registrar in natspec * js console api: setGlobalRegistrar, setHashReg, setUrlHint * js test TestContract uses mining - tests fixed all pass * eth/backend: allow PoW test mode (small ethash DAG) * console jsre refers to resolver.abi/addr, * cmd/geth/contracts.go moved to common/registrar
Diffstat (limited to 'common/natspec/natspec.go')
-rw-r--r--common/natspec/natspec.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/common/natspec/natspec.go b/common/natspec/natspec.go
index 7e5f053c7..9965a2227 100644
--- a/common/natspec/natspec.go
+++ b/common/natspec/natspec.go
@@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/docserver"
- "github.com/ethereum/go-ethereum/common/resolver"
+ "github.com/ethereum/go-ethereum/common/registrar"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/xeth"
)
@@ -88,7 +88,7 @@ func New(xeth *xeth.XEth, jsontx string, http *docserver.DocServer) (self *NatSp
}
// also called by admin.contractInfo.get
-func FetchDocsForContract(contractAddress string, xeth *xeth.XEth, http *docserver.DocServer) (content []byte, err error) {
+func FetchDocsForContract(contractAddress string, xeth *xeth.XEth, ds *docserver.DocServer) (content []byte, err error) {
// retrieve contract hash from state
codehex := xeth.CodeAt(contractAddress)
codeb := xeth.CodeAtBytes(contractAddress)
@@ -99,20 +99,32 @@ func FetchDocsForContract(contractAddress string, xeth *xeth.XEth, http *docserv
}
codehash := common.BytesToHash(crypto.Sha3(codeb))
// set up nameresolver with natspecreg + urlhint contract addresses
- res := resolver.New(xeth)
+ reg := registrar.New(xeth)
// resolve host via HashReg/UrlHint Resolver
- uri, hash, err := res.KeyToUrl(codehash)
+ hash, err := reg.HashToHash(codehash)
if err != nil {
return
}
+ if ds.HasScheme("bzz") {
+ content, err = ds.Get("bzz://"+hash.Hex()[2:], "")
+ if err == nil { // non-fatal
+ return
+ }
+ err = nil
+ //falling back to urlhint
+ }
- // get content via http client and authenticate content using hash
- content, err = http.GetAuthContent(uri, hash)
+ uri, err := reg.HashToUrl(hash)
if err != nil {
return
}
+ // get content via http client and authenticate content using hash
+ content, err = ds.GetAuthContent(uri, hash)
+ if err != nil {
+ return
+ }
return
}