From faa307362543bb89f10458e83aa03c557977937f Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 13 May 2014 22:25:05 +0200 Subject: [PATCH 01/10] Changed validators to regexp validators IntValidator limits to 32bit int (JavaScript limitation) and therefor the input fields are limited in length. --- ethereal/assets/qml/newTransaction/_new_contract.qml | 6 +++--- ethereal/assets/qml/newTransaction/_simple_send.qml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ethereal/assets/qml/newTransaction/_new_contract.qml b/ethereal/assets/qml/newTransaction/_new_contract.qml index f8f3d53a0..e3c7229eb 100644 --- a/ethereal/assets/qml/newTransaction/_new_contract.qml +++ b/ethereal/assets/qml/newTransaction/_new_contract.qml @@ -61,7 +61,7 @@ Component { id: txValue width: 200 placeholderText: "Amount" - validator: IntValidator { } + validator: RegExpValidator { regExp: /\d*/ } onTextChanged: { contractFormReady() } @@ -69,7 +69,7 @@ Component { TextField { id: txGas width: 200 - validator: IntValidator { } + validator: RegExpValidator { regExp: /\d*/ } placeholderText: "Gas" onTextChanged: { contractFormReady() @@ -79,7 +79,7 @@ Component { id: txGasPrice width: 200 placeholderText: "Gas price" - validator: IntValidator { } + validator: RegExpValidator { regExp: /\d*/ } onTextChanged: { contractFormReady() } diff --git a/ethereal/assets/qml/newTransaction/_simple_send.qml b/ethereal/assets/qml/newTransaction/_simple_send.qml index 12420c15a..cd1ef55b6 100644 --- a/ethereal/assets/qml/newTransaction/_simple_send.qml +++ b/ethereal/assets/qml/newTransaction/_simple_send.qml @@ -56,9 +56,10 @@ Component { } TextField { id: txSimpleValue + width: 200 placeholderText: "Amount" anchors.rightMargin: 5 - validator: IntValidator { } + validator: RegExpValidator { regExp: /\d*/ } onTextChanged: { checkFormState() } } Button { From 0d9c948b9b2c5eef6f0069f9aa05e9868f939444 Mon Sep 17 00:00:00 2001 From: Maran Date: Wed, 14 May 2014 12:24:49 +0200 Subject: [PATCH 02/10] Generate coinbase from privatekey, not pubkey. Partily fixes #43 --- ethereum/ethereum.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/ethereum.go b/ethereum/ethereum.go index babebbb48..055cc0bc4 100644 --- a/ethereum/ethereum.go +++ b/ethereum/ethereum.go @@ -138,7 +138,7 @@ func main() { go func() { data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) keyRing := ethutil.NewValueFromBytes(data) - addr := keyRing.Get(1).Bytes() + addr := keyRing.Get(0).Bytes() pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr))) From e8147cf7c6f508910698e6743ad347c78010ffe3 Mon Sep 17 00:00:00 2001 From: Maran Date: Wed, 14 May 2014 12:41:30 +0200 Subject: [PATCH 03/10] Refactored mining into utils and exposed it to ethereal. Partly fixes #43 --- ethereal/ethereum.go | 4 ++++ ethereum/ethereum.go | 25 +------------------------ utils/cmd.go | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 24 deletions(-) create mode 100644 utils/cmd.go diff --git a/ethereal/ethereum.go b/ethereal/ethereum.go index 15a454bdf..32c16f64f 100644 --- a/ethereal/ethereum.go +++ b/ethereal/ethereum.go @@ -99,6 +99,10 @@ func main() { os.Exit(0) } + if StartMining { + utils.DoMining(ethereum) + } + if StartRpc { ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort) if err != nil { diff --git a/ethereum/ethereum.go b/ethereum/ethereum.go index 055cc0bc4..207e61c88 100644 --- a/ethereum/ethereum.go +++ b/ethereum/ethereum.go @@ -1,11 +1,9 @@ package main import ( - "encoding/hex" "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" - "github.com/ethereum/eth-go/ethminer" "github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" @@ -127,28 +125,7 @@ func main() { ethereum.Mining = StartMining if StartMining { - logger.Infoln("Miner started") - - // Fake block mining. It broadcasts a new block every 5 seconds - go func() { - - if StartMining { - logger.Infoln("Miner started") - - go func() { - data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) - keyRing := ethutil.NewValueFromBytes(data) - addr := keyRing.Get(0).Bytes() - - pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr))) - - miner := ethminer.NewDefaultMiner(pair.Address(), ethereum) - miner.Start() - - }() - } - }() - + utils.DoMining(ethereum) } if StartConsole { diff --git a/utils/cmd.go b/utils/cmd.go new file mode 100644 index 000000000..a99fd9eed --- /dev/null +++ b/utils/cmd.go @@ -0,0 +1,31 @@ +package utils + +import ( + "encoding/hex" + "github.com/ethereum/eth-go" + "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethminer" + _ "github.com/ethereum/eth-go/ethrpc" + "github.com/ethereum/eth-go/ethutil" + "log" +) + +func DoMining(ethereum *eth.Ethereum) { + // Set Mining status + ethereum.Mining = true + + log.Println("Miner started") + + // Fake block mining. It broadcasts a new block every 5 seconds + go func() { + data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) + keyRing := ethutil.NewValueFromBytes(data) + addr := keyRing.Get(0).Bytes() + + pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr))) + + miner := ethminer.NewDefaultMiner(pair.Address(), ethereum) + miner.Start() + + }() +} From 2012e0c67abd8e3012a3eb1fae2e282e2a442d01 Mon Sep 17 00:00:00 2001 From: Maran Date: Wed, 14 May 2014 13:26:15 +0200 Subject: [PATCH 04/10] Rewritten a check to only start mining once we are caught up with all peers --- utils/cmd.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/utils/cmd.go b/utils/cmd.go index a99fd9eed..44924ce91 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -8,24 +8,27 @@ import ( _ "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "log" + "time" ) func DoMining(ethereum *eth.Ethereum) { // Set Mining status ethereum.Mining = true - log.Println("Miner started") - - // Fake block mining. It broadcasts a new block every 5 seconds go func() { + // Give it some time to connect with peers + time.Sleep(3 * time.Second) + + for ethereum.IsUpToDate() == false { + time.Sleep(5 * time.Second) + } + log.Println("Miner started") + data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) keyRing := ethutil.NewValueFromBytes(data) addr := keyRing.Get(0).Bytes() - pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr))) - miner := ethminer.NewDefaultMiner(pair.Address(), ethereum) miner.Start() - }() } From 9fce273ce97a8db091a0bf9d0b503a2ea7261f81 Mon Sep 17 00:00:00 2001 From: Maran Date: Wed, 14 May 2014 13:32:49 +0200 Subject: [PATCH 05/10] Refactored RPC client to utils so it can be reused --- ethereal/ethereum.go | 9 +-------- ethereum/ethereum.go | 9 +-------- utils/cmd.go | 13 ++++++++++++- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/ethereal/ethereum.go b/ethereal/ethereum.go index 32c16f64f..a97d7f498 100644 --- a/ethereal/ethereum.go +++ b/ethereal/ethereum.go @@ -4,8 +4,6 @@ import ( "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" - "github.com/ethereum/eth-go/ethpub" - "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/go-ethereum/ethereal/ui" "github.com/ethereum/go-ethereum/utils" @@ -104,12 +102,7 @@ func main() { } if StartRpc { - ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort) - if err != nil { - log.Println("Could not start RPC interface:", err) - } else { - go ethereum.RpcServer.Start() - } + utils.DoRpc(ethereum, RpcPort) } log.Printf("Starting Ethereum GUI v%s\n", ethutil.Config.Ver) diff --git a/ethereum/ethereum.go b/ethereum/ethereum.go index 207e61c88..448223c37 100644 --- a/ethereum/ethereum.go +++ b/ethereum/ethereum.go @@ -4,8 +4,6 @@ import ( "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" - "github.com/ethereum/eth-go/ethpub" - "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/go-ethereum/utils" "log" @@ -139,12 +137,7 @@ func main() { go console.Start() } if StartRpc { - ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort) - if err != nil { - logger.Infoln("Could not start RPC interface:", err) - } else { - go ethereum.RpcServer.Start() - } + utils.DoRpc(ethereum, RpcPort) } RegisterInterrupts(ethereum) diff --git a/utils/cmd.go b/utils/cmd.go index 44924ce91..5a100ca4f 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -5,12 +5,23 @@ import ( "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethminer" - _ "github.com/ethereum/eth-go/ethrpc" + "github.com/ethereum/eth-go/ethpub" + "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "log" "time" ) +func DoRpc(ethereum *eth.Ethereum, RpcPort int) { + var err error + ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort) + if err != nil { + log.Println("Could not start RPC interface:", err) + } else { + go ethereum.RpcServer.Start() + } +} + func DoMining(ethereum *eth.Ethereum) { // Set Mining status ethereum.Mining = true From f18ec51cb3959cc662bfc7b84314cd1d3b1541b5 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 14 May 2014 13:55:08 +0200 Subject: [PATCH 06/10] Switched to new keyring methods --- README.md | 2 +- ethereal/assets/muted/index.html | 1 + ethereal/assets/samplecoin/samplecoin.html | 4 +- ethereal/ethereum.go | 15 +++++- ethereal/ui/gui.go | 49 ++----------------- ethereal/ui/library.go | 13 +++-- ethereal/ui/ui_lib.go | 2 +- ethereum/dev_console.go | 8 +-- ethereum/ethereum.go | 15 +++++- utils/cmd.go | 11 ++--- utils/keys.go | 57 ++++++++++++++++++++++ 11 files changed, 106 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 685d4c6d9..35c97c8ee 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Ethereum Ethereum Go Client © 2014 Jeffrey Wilcke. -Current state: Proof of Concept 5.0 RC3. +Current state: Proof of Concept 5.0 RC4. For the development package please see the [eth-go package](https://github.com/ethereum/eth-go). diff --git a/ethereal/assets/muted/index.html b/ethereal/assets/muted/index.html index 84584e373..14949b5ac 100644 --- a/ethereal/assets/muted/index.html +++ b/ethereal/assets/muted/index.html @@ -46,6 +46,7 @@ .CodeMirror { height: 70%; + font-size: 14pt; } diff --git a/ethereal/assets/samplecoin/samplecoin.html b/ethereal/assets/samplecoin/samplecoin.html index 384936780..3f8eacc00 100644 --- a/ethereal/assets/samplecoin/samplecoin.html +++ b/ethereal/assets/samplecoin/samplecoin.html @@ -9,7 +9,7 @@