forked from cerc-io/plugeth
repl.Stop() to only if running, fixes panic after js> exit followed by interrupt
This commit is contained in:
parent
bf57e9603b
commit
6763d28a17
@ -23,6 +23,8 @@ type JSRepl struct {
|
|||||||
prompt string
|
prompt string
|
||||||
|
|
||||||
history *os.File
|
history *os.File
|
||||||
|
|
||||||
|
running bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
|
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
|
||||||
@ -35,6 +37,8 @@ func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSRepl) Start() {
|
func (self *JSRepl) Start() {
|
||||||
|
if !self.running {
|
||||||
|
self.running = true
|
||||||
logger.Infoln("init JS Console")
|
logger.Infoln("init JS Console")
|
||||||
reader := bufio.NewReader(self.history)
|
reader := bufio.NewReader(self.history)
|
||||||
for {
|
for {
|
||||||
@ -50,12 +54,16 @@ func (self *JSRepl) Start() {
|
|||||||
}
|
}
|
||||||
self.read()
|
self.read()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *JSRepl) Stop() {
|
func (self *JSRepl) Stop() {
|
||||||
|
if self.running {
|
||||||
|
self.running = false
|
||||||
self.re.Stop()
|
self.re.Stop()
|
||||||
logger.Infoln("exit JS Console")
|
logger.Infoln("exit JS Console")
|
||||||
self.history.Close()
|
self.history.Close()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *JSRepl) parseInput(code string) {
|
func (self *JSRepl) parseInput(code string) {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user