diff options
author | zelig <viktor.tron@gmail.com> | 2015-10-27 05:24:09 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-10-27 05:24:09 +0800 |
commit | 4d005a2c1d2929dc770acd3a2bfed59495c70557 (patch) | |
tree | 0442ccefd85cc8b692c2c58a5916bc997909657a /common/natspec | |
parent | 3b4ffacd0c63952ceda96b3fafb050c91e72b420 (diff) | |
download | dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.tar dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.tar.gz dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.tar.bz2 dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.tar.lz dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.tar.xz dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.tar.zst dexon-4d005a2c1d2929dc770acd3a2bfed59495c70557.zip |
rpc api: eth_getNatSpec
* xeth, rpc: implement eth_getNatSpec for tx confirmations
* rename silly docserver -> httpclient
* eth/backend: httpclient now accessible via eth.Ethereum init-d via config.DocRoot
* cmd: introduce separate CLI flag for DocRoot (defaults to homedir)
* common/path: delete unused assetpath func, separate HomeDir func
Diffstat (limited to 'common/natspec')
-rw-r--r-- | common/natspec/natspec.go | 14 | ||||
-rw-r--r-- | common/natspec/natspec_e2e_test.go | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/common/natspec/natspec.go b/common/natspec/natspec.go index 0265c2e13..d9627b4e1 100644 --- a/common/natspec/natspec.go +++ b/common/natspec/natspec.go @@ -23,7 +23,7 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/docserver" + "github.com/ethereum/go-ethereum/common/httpclient" "github.com/ethereum/go-ethereum/common/registrar" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/xeth" @@ -43,7 +43,7 @@ type NatSpec struct { // the implementation is frontend friendly in that it always gives back // a notice that is safe to display // :FIXME: the second return value is an error, which can be used to fine-tune bahaviour -func GetNotice(xeth *xeth.XEth, tx string, http *docserver.DocServer) (notice string) { +func GetNotice(xeth *xeth.XEth, tx string, http *httpclient.HTTPClient) (notice string) { ns, err := New(xeth, tx, http) if err != nil { if ns == nil { @@ -83,7 +83,7 @@ type contractInfo struct { DeveloperDoc json.RawMessage `json:"developerDoc"` } -func New(xeth *xeth.XEth, jsontx string, http *docserver.DocServer) (self *NatSpec, err error) { +func New(xeth *xeth.XEth, jsontx string, http *httpclient.HTTPClient) (self *NatSpec, err error) { // extract contract address from tx var tx jsonTx @@ -104,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, ds *docserver.DocServer) (content []byte, err error) { +func FetchDocsForContract(contractAddress string, xeth *xeth.XEth, client *httpclient.HTTPClient) (content []byte, err error) { // retrieve contract hash from state codehex := xeth.CodeAt(contractAddress) codeb := xeth.CodeAtBytes(contractAddress) @@ -122,8 +122,8 @@ func FetchDocsForContract(contractAddress string, xeth *xeth.XEth, ds *docserver if err != nil { return } - if ds.HasScheme("bzz") { - content, err = ds.Get("bzz://"+hash.Hex()[2:], "") + if client.HasScheme("bzz") { + content, err = client.Get("bzz://"+hash.Hex()[2:], "") if err == nil { // non-fatal return } @@ -137,7 +137,7 @@ func FetchDocsForContract(contractAddress string, xeth *xeth.XEth, ds *docserver } // get content via http client and authenticate content using hash - content, err = ds.GetAuthContent(uri, hash) + content, err = client.GetAuthContent(uri, hash) if err != nil { return } diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go index 4149314c3..706a294ec 100644 --- a/common/natspec/natspec_e2e_test.go +++ b/common/natspec/natspec_e2e_test.go @@ -28,7 +28,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/docserver" + "github.com/ethereum/go-ethereum/common/httpclient" "github.com/ethereum/go-ethereum/common/registrar" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" @@ -113,8 +113,8 @@ func (self *testFrontend) UnlockAccount(acc []byte) bool { func (self *testFrontend) ConfirmTransaction(tx string) bool { if self.wantNatSpec { - ds := docserver.New("/tmp/") - self.lastConfirm = GetNotice(self.xeth, tx, ds) + client := httpclient.New("/tmp/") + self.lastConfirm = GetNotice(self.xeth, tx, client) } return true } |