aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-10-27 05:24:09 +0800
committerzelig <viktor.tron@gmail.com>2015-10-27 05:24:09 +0800
commit4d005a2c1d2929dc770acd3a2bfed59495c70557 (patch)
tree0442ccefd85cc8b692c2c58a5916bc997909657a /cmd
parent3b4ffacd0c63952ceda96b3fafb050c91e72b420 (diff)
downloaddexon-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 'cmd')
-rw-r--r--cmd/geth/js.go31
-rw-r--r--cmd/geth/js_test.go10
-rw-r--r--cmd/utils/flags.go10
3 files changed, 26 insertions, 25 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index 7f7f19d78..4d5462539 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -30,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/docserver"
"github.com/ethereum/go-ethereum/common/natspec"
"github.com/ethereum/go-ethereum/common/registrar"
"github.com/ethereum/go-ethereum/eth"
@@ -77,8 +76,6 @@ func (r dumbterm) PasswordPrompt(p string) (string, error) {
func (r dumbterm) AppendHistory(string) {}
type jsre struct {
- docRoot string
- ds *docserver.DocServer
re *re.JSRE
ethereum *eth.Ethereum
xeth *xeth.XEth
@@ -153,7 +150,6 @@ func newLightweightJSRE(docRoot string, client comms.EthereumClient, datadir str
js := &jsre{ps1: "> "}
js.wait = make(chan *big.Int)
js.client = client
- js.ds = docserver.New(docRoot)
// update state in separare forever blocks
js.re = re.New(docRoot)
@@ -181,18 +177,17 @@ func newLightweightJSRE(docRoot string, client comms.EthereumClient, datadir str
}
func newJSRE(ethereum *eth.Ethereum, docRoot, corsDomain string, client comms.EthereumClient, interactive bool, f xeth.Frontend) *jsre {
- js := &jsre{ethereum: ethereum, ps1: "> ", docRoot: docRoot}
+ js := &jsre{ethereum: ethereum, ps1: "> "}
// set default cors domain used by startRpc from CLI flag
js.corsDomain = corsDomain
if f == nil {
f = js
}
- js.ds = docserver.New(docRoot)
js.xeth = xeth.New(ethereum, f)
js.wait = js.xeth.UpdateState()
js.client = client
if clt, ok := js.client.(*comms.InProcClient); ok {
- if offeredApis, err := api.ParseApiString(shared.AllApis, codec.JSON, js.xeth, ethereum, docRoot); err == nil {
+ if offeredApis, err := api.ParseApiString(shared.AllApis, codec.JSON, js.xeth, ethereum); err == nil {
clt.Initialize(api.Merge(offeredApis...))
}
}
@@ -248,14 +243,14 @@ func (self *jsre) batch(statement string) {
// show summary of current geth instance
func (self *jsre) welcome() {
self.re.Run(`
- (function () {
- console.log('instance: ' + web3.version.client);
- console.log(' datadir: ' + admin.datadir);
- console.log("coinbase: " + eth.coinbase);
- var ts = 1000 * eth.getBlock(eth.blockNumber).timestamp;
- console.log("at block: " + eth.blockNumber + " (" + new Date(ts) + ")");
- })();
- `)
+ (function () {
+ console.log('instance: ' + web3.version.client);
+ console.log(' datadir: ' + admin.datadir);
+ console.log("coinbase: " + eth.coinbase);
+ var ts = 1000 * eth.getBlock(eth.blockNumber).timestamp;
+ console.log("at block: " + eth.blockNumber + " (" + new Date(ts) + ")");
+ })();
+ `)
if modules, err := self.supportedApis(); err == nil {
loadedModules := make([]string, 0)
for api, version := range modules {
@@ -281,7 +276,7 @@ func (js *jsre) apiBindings(f xeth.Frontend) error {
apiNames = append(apiNames, a)
}
- apiImpl, err := api.ParseApiString(strings.Join(apiNames, ","), codec.JSON, js.xeth, js.ethereum, js.docRoot)
+ apiImpl, err := api.ParseApiString(strings.Join(apiNames, ","), codec.JSON, js.xeth, js.ethereum)
if err != nil {
utils.Fatalf("Unable to determine supported api's: %v", err)
}
@@ -334,7 +329,7 @@ func (js *jsre) apiBindings(f xeth.Frontend) error {
utils.Fatalf("Error setting namespaces: %v", err)
}
- js.re.Run(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`)
+ js.re.Run(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`)
return nil
}
@@ -348,7 +343,7 @@ func (self *jsre) AskPassword() (string, bool) {
func (self *jsre) ConfirmTransaction(tx string) bool {
if self.ethereum.NatSpec {
- notice := natspec.GetNotice(self.xeth, tx, self.ds)
+ notice := natspec.GetNotice(self.xeth, tx, self.ethereum.HTTPClient())
fmt.Println(notice)
answer, _ := self.Prompt("Confirm Transaction [y/n]")
return strings.HasPrefix(strings.Trim(answer, " "), "y")
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index 09cc88519..477079706 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -31,7 +31,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/compiler"
- "github.com/ethereum/go-ethereum/common/docserver"
+ "github.com/ethereum/go-ethereum/common/httpclient"
"github.com/ethereum/go-ethereum/common/natspec"
"github.com/ethereum/go-ethereum/common/registrar"
"github.com/ethereum/go-ethereum/core"
@@ -62,7 +62,7 @@ var (
type testjethre struct {
*jsre
lastConfirm string
- ds *docserver.DocServer
+ client *httpclient.HTTPClient
}
func (self *testjethre) UnlockAccount(acc []byte) bool {
@@ -75,7 +75,7 @@ func (self *testjethre) UnlockAccount(acc []byte) bool {
func (self *testjethre) ConfirmTransaction(tx string) bool {
if self.ethereum.NatSpec {
- self.lastConfirm = natspec.GetNotice(self.xeth, tx, self.ds)
+ self.lastConfirm = natspec.GetNotice(self.xeth, tx, self.client)
}
return true
}
@@ -101,6 +101,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth
AccountManager: am,
MaxPeers: 0,
Name: "test",
+ DocRoot: "/",
SolcPath: testSolcPath,
PowTest: true,
NewDB: func(path string) (ethdb.Database, error) { return db, nil },
@@ -130,8 +131,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth
assetPath := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext")
client := comms.NewInProcClient(codec.JSON)
- ds := docserver.New("/")
- tf := &testjethre{ds: ds}
+ tf := &testjethre{client: ethereum.HTTPClient()}
repl := newJSRE(ethereum, assetPath, "", client, false, tf)
tf.jsre = repl
return tmp, tf, ethereum
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 66ec46f80..79c86c52a 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -139,6 +139,11 @@ var (
Name: "natspec",
Usage: "Enable NatSpec confirmation notice",
}
+ DocRootFlag = DirectoryFlag{
+ Name: "docroot",
+ Usage: "Document Root for HTTPClient file scheme",
+ Value: DirectoryString{common.HomeDir()},
+ }
CacheFlag = cli.IntFlag{
Name: "cache",
Usage: "Megabytes of memory allocated to internal caching",
@@ -452,6 +457,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
Olympic: ctx.GlobalBool(OlympicFlag.Name),
NAT: MakeNAT(ctx),
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
+ DocRoot: ctx.GlobalString(DocRootFlag.Name),
Discovery: !ctx.GlobalBool(NoDiscoverFlag.Name),
NodeKey: MakeNodeKey(ctx),
Shh: ctx.GlobalBool(WhisperEnabledFlag.Name),
@@ -616,7 +622,7 @@ func StartIPC(eth *eth.Ethereum, ctx *cli.Context) error {
xeth := xeth.New(eth, fe)
codec := codec.JSON
- apis, err := api.ParseApiString(ctx.GlobalString(IPCApiFlag.Name), codec, xeth, eth, ctx.GlobalString(JSpathFlag.Name))
+ apis, err := api.ParseApiString(ctx.GlobalString(IPCApiFlag.Name), codec, xeth, eth)
if err != nil {
return nil, err
}
@@ -637,7 +643,7 @@ func StartRPC(eth *eth.Ethereum, ctx *cli.Context) error {
xeth := xeth.New(eth, nil)
codec := codec.JSON
- apis, err := api.ParseApiString(ctx.GlobalString(RpcApiFlag.Name), codec, xeth, eth, ctx.GlobalString(JSpathFlag.Name))
+ apis, err := api.ParseApiString(ctx.GlobalString(RpcApiFlag.Name), codec, xeth, eth)
if err != nil {
return err
}