Commit 34284b75 authored by zelig's avatar zelig

merge upstream

parents 10247665 176b7802
package main package main
import ( import (
"fmt" "fmt"
...@@ -144,6 +144,7 @@ func (self *JSRE) initStdFuncs() { ...@@ -144,6 +144,7 @@ func (self *JSRE) initStdFuncs() {
eth.Set("require", self.require) eth.Set("require", self.require)
eth.Set("stopMining", self.stopMining) eth.Set("stopMining", self.stopMining)
eth.Set("startMining", self.startMining) eth.Set("startMining", self.startMining)
eth.Set("blockDo", self.execBlock)
} }
/* /*
...@@ -213,3 +214,18 @@ func (self *JSRE) require(call otto.FunctionCall) otto.Value { ...@@ -213,3 +214,18 @@ func (self *JSRE) require(call otto.FunctionCall) otto.Value {
return t return t
} }
func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value {
hash, err := call.Argument(0).ToString()
if err != nil {
return otto.UndefinedValue()
}
err = self.ethereum.BlockDo(ethutil.FromHex(hash))
if err != nil {
fmt.Println(err)
return otto.FalseValue()
}
return otto.TrueValue()
}
...@@ -198,9 +198,6 @@ func StartMining(ethereum *eth.Ethereum) bool { ...@@ -198,9 +198,6 @@ func StartMining(ethereum *eth.Ethereum) bool {
miner = ethminer.NewDefaultMiner(addr, ethereum) miner = ethminer.NewDefaultMiner(addr, ethereum)
// Give it some time to connect with peers // Give it some time to connect with peers
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
for ethereum.IsUpToDate() == false {
time.Sleep(5 * time.Second)
}
logger.Infoln("Miner started") logger.Infoln("Miner started")
miner := ethminer.NewDefaultMiner(addr, ethereum) miner := ethminer.NewDefaultMiner(addr, ethereum)
miner.Start() miner.Start()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment