aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-06-25 23:20:26 +0800
committerzelig <viktor.tron@gmail.com>2014-06-25 23:20:26 +0800
commit08de13a57b4a59fc4a8ccf9e707ede57cc380a0c (patch)
tree94bd0dc4887284c6e0ae57a7b40825dae52eee0e /ethereum
parent6f09a3e8200ba2eeeeb296141d6644d04078a9c4 (diff)
parent9654b809120d1cc3c53ffe268fe47869ef0dc0a8 (diff)
downloadgo-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.tar
go-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.tar.gz
go-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.tar.bz2
go-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.tar.lz
go-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.tar.xz
go-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.tar.zst
go-tangerine-08de13a57b4a59fc4a8ccf9e707ede57cc380a0c.zip
merge upstream
Diffstat (limited to 'ethereum')
-rw-r--r--ethereum/javascript_runtime.go4
-rw-r--r--ethereum/repl.go27
-rw-r--r--ethereum/repl_darwin.go4
3 files changed, 31 insertions, 4 deletions
diff --git a/ethereum/javascript_runtime.go b/ethereum/javascript_runtime.go
index ac05be69b..0a9a882ad 100644
--- a/ethereum/javascript_runtime.go
+++ b/ethereum/javascript_runtime.go
@@ -144,7 +144,7 @@ func (self *JSRE) initStdFuncs() {
eth.Set("require", self.require)
eth.Set("stopMining", self.stopMining)
eth.Set("startMining", self.startMining)
- eth.Set("blockDo", self.execBlock)
+ eth.Set("execBlock", self.execBlock)
}
/*
@@ -221,7 +221,7 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value {
return otto.UndefinedValue()
}
- err = self.ethereum.BlockDo(ethutil.FromHex(hash))
+ err = utils.BlockDo(self.ethereum, ethutil.FromHex(hash))
if err != nil {
fmt.Println(err)
return otto.FalseValue()
diff --git a/ethereum/repl.go b/ethereum/repl.go
index a95d73300..c162c78b0 100644
--- a/ethereum/repl.go
+++ b/ethereum/repl.go
@@ -1,10 +1,15 @@
package main
import (
+ "bufio"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethpub"
+ "github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/otto"
+ "io"
+ "os"
+ "path"
)
type Repl interface {
@@ -16,20 +21,40 @@ type JSRepl struct {
re *JSRE
prompt string
+
+ history *os.File
}
func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
- return &JSRepl{re: NewJSRE(ethereum), prompt: "> "}
+ hist, err := os.OpenFile(path.Join(ethutil.Config.ExecPath, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
+ if err != nil {
+ panic(err)
+ }
+
+ return &JSRepl{re: NewJSRE(ethereum), prompt: "> ", history: hist}
}
func (self *JSRepl) Start() {
logger.Infoln("init JS Console")
+ reader := bufio.NewReader(self.history)
+ for {
+ line, err := reader.ReadString('\n')
+ if err != nil && err == io.EOF {
+ break
+ } else if err != nil {
+ fmt.Println("error reading history", err)
+ break
+ }
+
+ addHistory(line[:len(line)-1])
+ }
self.read()
}
func (self *JSRepl) Stop() {
self.re.Stop()
logger.Infoln("exit JS Console")
+ self.history.Close()
}
func (self *JSRepl) parseInput(code string) {
diff --git a/ethereum/repl_darwin.go b/ethereum/repl_darwin.go
index b61d4edd7..62b40059a 100644
--- a/ethereum/repl_darwin.go
+++ b/ethereum/repl_darwin.go
@@ -102,7 +102,9 @@ L:
break L
}
- addHistory(str[:len(str)-1]) //allow user to recall this line
+ hist := str[:len(str)-1]
+ addHistory(hist) //allow user to recall this line
+ self.history.WriteString(str)
self.parseInput(str)