aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/js.go31
-rw-r--r--cmd/geth/js_test.go10
2 files changed, 18 insertions, 23 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