mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/geth: fix stack trace when admin is missing
This commit is contained in:
parent
fc082e6edf
commit
71b70f2eea
2 changed files with 11 additions and 9 deletions
|
|
@ -139,7 +139,9 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
|
||||||
attach.SetTemplateFunc("gover", runtime.Version)
|
attach.SetTemplateFunc("gover", runtime.Version)
|
||||||
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
|
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
|
||||||
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
|
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
|
||||||
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
attach.SetTemplateFunc("niltime", func() string {
|
||||||
|
return time.Unix(0, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
||||||
|
})
|
||||||
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
||||||
attach.SetTemplateFunc("datadir", func() string { return geth.Datadir })
|
attach.SetTemplateFunc("datadir", func() string { return geth.Datadir })
|
||||||
attach.SetTemplateFunc("apis", func() string { return apis })
|
attach.SetTemplateFunc("apis", func() string { return apis })
|
||||||
|
|
|
||||||
|
|
@ -206,14 +206,14 @@ func (c *Console) init(preload []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The admin.sleep and admin.sleepBlocks are offered by the console and not by the RPC layer.
|
// The admin.sleep and admin.sleepBlocks are offered by the console and not by the RPC layer.
|
||||||
admin := c.jsre.Get("admin")
|
admin := c.jsre.Get("admin") // Could be `nil`
|
||||||
if admin == nil {
|
if admin != nil {
|
||||||
return fmt.Errorf("could not find admin")
|
// make sure the admin api is enabled over the interface
|
||||||
}
|
if obj := admin.ToObject(c.runtime); obj != nil {
|
||||||
if obj := admin.ToObject(c.runtime); obj != nil { // make sure the admin api is enabled over the interface
|
obj.Set("sleepBlocks", bridge.SleepBlocks)
|
||||||
obj.Set("sleepBlocks", bridge.SleepBlocks)
|
obj.Set("sleep", bridge.Sleep)
|
||||||
obj.Set("sleep", bridge.Sleep)
|
obj.Set("clearHistory", c.clearHistory)
|
||||||
obj.Set("clearHistory", c.clearHistory)
|
}
|
||||||
}
|
}
|
||||||
// Preload any JavaScript files before starting the console
|
// Preload any JavaScript files before starting the console
|
||||||
for _, path := range preload {
|
for _, path := range preload {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue