aboutsummaryrefslogtreecommitdiffstats
path: root/common/natspec/natspec.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 21:12:56 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 21:12:56 +0800
commit193c62fdba3bb5c40daad6652c18d81d43518235 (patch)
tree4b77244b1ce72160a1434036977c7a473781665c /common/natspec/natspec.go
parenta2ce7b99501b3273b4cee65cd6784c7d1c4645f7 (diff)
parentd673c34c8d4ae83a3765ed44ae9d0fb7ce1aa3c9 (diff)
downloadgo-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.tar
go-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.tar.gz
go-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.tar.bz2
go-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.tar.lz
go-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.tar.xz
go-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.tar.zst
go-tangerine-193c62fdba3bb5c40daad6652c18d81d43518235.zip
Merge branch 'release/0.9.36'
Diffstat (limited to 'common/natspec/natspec.go')
-rw-r--r--common/natspec/natspec.go42
1 files changed, 35 insertions, 7 deletions
diff --git a/common/natspec/natspec.go b/common/natspec/natspec.go
index 7e5f053c7..ed16d62a0 100644
--- a/common/natspec/natspec.go
+++ b/common/natspec/natspec.go
@@ -1,17 +1,33 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
package natspec
import (
"bytes"
"encoding/json"
"fmt"
- "github.com/robertkrimen/otto"
"strings"
"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"
+ "github.com/robertkrimen/otto"
)
type abi2method map[[8]byte]*method
@@ -88,7 +104,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 +115,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
}