miner: provide coinbase when starting the miner

This avoids having to query the coinbase when creating the miner, which
in turn eliminates the dreaded startup error when no accounts are set
up. Later, this will also allow us to simply restart the miner when the
user picks a different coinbase.

This causes a lot of changes in other packages. These are included in
this commit because they're impossible to separate.
This commit is contained in:
Felix Lange
2015-03-11 23:35:34 +01:00
parent 5a9f712144
commit d7b5a87b3b
8 changed files with 74 additions and 87 deletions

View File

@ -249,12 +249,14 @@ func (self *jsre) dump(call otto.FunctionCall) otto.Value {
}
func (self *jsre) stopMining(call otto.FunctionCall) otto.Value {
self.xeth.Miner().Stop()
self.ethereum.StopMining()
return otto.TrueValue()
}
func (self *jsre) startMining(call otto.FunctionCall) otto.Value {
self.xeth.Miner().Start()
if err := self.ethereum.StartMining(); err != nil {
return otto.FalseValue()
}
return otto.TrueValue()
}

View File

@ -214,7 +214,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
utils.StartRPC(eth, ctx)
}
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
eth.Miner().Start()
eth.StartMining()
}
}

View File

@ -55,8 +55,8 @@ Rectangle {
Button {
text: "Start"
onClicked: {
eth.setGasPrice(minGasPrice.text || "10000000000000");
eth.setExtra(blockExtra.text)
// eth.setGasPrice(minGasPrice.text || "10000000000000");
// eth.setExtra(blockExtra.text)
if (eth.toggleMining()) {
this.text = "Stop";
} else {
@ -65,35 +65,35 @@ Rectangle {
}
}
Rectangle {
id: minGasPriceRect
anchors.top: parent.top
anchors.topMargin: 2
width: 200
TextField {
id: minGasPrice
placeholderText: "Min Gas: 10000000000000"
width: 200
validator: RegExpValidator { regExp: /\d*/ }
}
}
// Rectangle {
// id: minGasPriceRect
// anchors.top: parent.top
// anchors.topMargin: 2
// width: 200
// TextField {
// id: minGasPrice
// placeholderText: "Min Gas: 10000000000000"
// width: 200
// validator: RegExpValidator { regExp: /\d*/ }
// }
// }
Rectangle {
width: 300
anchors {
left: minGasPriceRect.right
leftMargin: 5
top: parent.top
topMargin: 2
}
// Rectangle {
// width: 300
// anchors {
// left: minGasPriceRect.right
// leftMargin: 5
// top: parent.top
// topMargin: 2
// }
TextField {
id: blockExtra
placeholderText: "Extra"
width: parent.width
maximumLength: 1024
}
}
// TextField {
// id: blockExtra
// placeholderText: "Extra"
// width: parent.width
// maximumLength: 1024
// }
// }
}
}

View File

@ -93,7 +93,6 @@ Rectangle {
// Check if it's mining and set it accordingly
if (miningSliderValue > 0 && !eth.miner().mining()) {
// If the
eth.setGasPrice("10000000000000");
eth.miner().start();
} else if (miningSliderValue == 0 && eth.miner().mining()) {
eth.miner().stop();

View File

@ -175,22 +175,12 @@ func (self *UiLib) RemoveLocalTransaction(id int) {
//self.miner.RemoveLocalTx(id)
}
func (self *UiLib) SetGasPrice(price string) {
self.Miner().MinAcceptedGasPrice = ethutil.Big(price)
}
func (self *UiLib) SetExtra(extra string) {
self.Miner().Extra = extra
}
func (self *UiLib) ToggleMining() bool {
if !self.Miner().Mining() {
self.Miner().Start()
return true
if !self.eth.IsMining() {
err := self.eth.StartMining()
return err == nil
} else {
self.Miner().Stop()
self.eth.StopMining()
return false
}
}