aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mist/ui_lib.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-11-07 19:18:48 +0800
committerobscuren <geffobscura@gmail.com>2014-11-07 19:18:48 +0800
commit429dd2a100f3b9e2b612b59bcb48f79a805cd6f9 (patch)
treec91fee673e461a192d4d783193c8ddbead4a97d2 /cmd/mist/ui_lib.go
parent48488017e498916c81122c01cfe1880afdd00d48 (diff)
downloaddexon-429dd2a100f3b9e2b612b59bcb48f79a805cd6f9.tar.gz
dexon-429dd2a100f3b9e2b612b59bcb48f79a805cd6f9.tar.zst
dexon-429dd2a100f3b9e2b612b59bcb48f79a805cd6f9.zip
Implemented new miner w/ ui interface for merged mining. Closes #177
* Miner has been rewritten * Added new miner pane * Added option for local txs * Added option to read from MergeMining contract and list them for merged mining
Diffstat (limited to 'cmd/mist/ui_lib.go')
-rw-r--r--cmd/mist/ui_lib.go38
1 files changed, 37 insertions, 1 deletions
diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go
index bb978707d..bdf551325 100644
--- a/cmd/mist/ui_lib.go
+++ b/cmd/mist/ui_lib.go
@@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/javascript"
+ "github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/ui/qt"
"github.com/ethereum/go-ethereum/xeth"
@@ -55,10 +56,15 @@ type UiLib struct {
jsEngine *javascript.JSRE
filterCallbacks map[int][]int
+
+ miner *miner.Miner
}
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
- return &UiLib{JSXEth: xeth.NewJSXEth(eth), engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(eth), filterCallbacks: make(map[int][]int)} //, filters: make(map[int]*xeth.JSFilter)}
+ lib := &UiLib{JSXEth: xeth.NewJSXEth(eth), engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(eth), filterCallbacks: make(map[int][]int)} //, filters: make(map[int]*xeth.JSFilter)}
+ lib.miner = miner.New(eth.KeyManager().Address(), eth)
+
+ return lib
}
func (self *UiLib) Notef(args []interface{}) {
@@ -328,3 +334,33 @@ func (self *UiLib) Call(params map[string]interface{}) (string, error) {
object["data"],
)
}
+
+func (self *UiLib) AddLocalTransaction(to, data, gas, gasPrice, value string) int {
+ return self.miner.AddLocalTx(&miner.LocalTx{
+ To: ethutil.Hex2Bytes(to),
+ Data: ethutil.Hex2Bytes(data),
+ Gas: gas,
+ GasPrice: gasPrice,
+ Value: value,
+ }) - 1
+}
+
+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) ToggleMining() bool {
+ if !self.miner.Mining() {
+ self.miner.Start()
+
+ return true
+ } else {
+ self.miner.Stop()
+
+ return false
+ }
+}