aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-21 19:37:40 +0800
committerobscuren <geffobscura@gmail.com>2014-02-21 19:37:40 +0800
commit05c353eca0c4e01457412dd643529200816ab159 (patch)
tree2294ad6c7976dcf4880dae5d7544a99c22947b74 /ethereum.go
parentd7ecc92c4134e3987b2b370bb53b0cd560fc0f7b (diff)
downloadgo-tangerine-05c353eca0c4e01457412dd643529200816ab159.tar.gz
go-tangerine-05c353eca0c4e01457412dd643529200816ab159.tar.zst
go-tangerine-05c353eca0c4e01457412dd643529200816ab159.zip
Added a basic <UNSTABLE> UI
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go86
1 files changed, 50 insertions, 36 deletions
diff --git a/ethereum.go b/ethereum.go
index 36700a6d4..5eda09a44 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -5,6 +5,8 @@ import (
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
+ "github.com/ethereum/go-ethereum/ui"
+ "github.com/niemeyer/qml"
"github.com/obscuren/secp256k1-go"
"log"
"os"
@@ -76,9 +78,16 @@ pubk: %x
}
func main() {
- runtime.GOMAXPROCS(runtime.NumCPU())
Init()
+ // Qt has to be initialized in the main thread or it will throw errors
+ // It has to be called BEFORE setting the maximum procs.
+ if UseGui {
+ qml.Init(nil)
+ }
+
+ runtime.GOMAXPROCS(runtime.NumCPU())
+
ethchain.InitFees()
ethutil.ReadConfig(".ethereum")
ethutil.Config.Seed = UseSeed
@@ -156,41 +165,46 @@ func main() {
go console.Start()
}
- RegisterInterupts(ethereum)
-
- ethereum.Start()
-
- if StartMining {
- log.Printf("Miner started\n")
-
- // Fake block mining. It broadcasts a new block every 5 seconds
- go func() {
- pow := &ethchain.EasyPow{}
- data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
- keyRing := ethutil.NewValueFromBytes(data)
- addr := keyRing.Get(1).Bytes()
-
- for {
- txs := ethereum.TxPool.Flush()
- // Create a new block which we're going to mine
- block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs)
- // Apply all transactions to the block
- ethereum.BlockManager.ApplyTransactions(block, block.Transactions())
-
- ethereum.BlockManager.AccumelateRewards(block, block)
-
- // Search the nonce
- block.Nonce = pow.Search(block)
- err := ethereum.BlockManager.ProcessBlock(block)
- if err != nil {
- log.Println(err)
- } else {
- log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockManager.BlockChain().CurrentBlock)
+ if UseGui {
+ gui := ethui.New(ethereum)
+ gui.Start()
+ //ethereum.Stop()
+ } else {
+ RegisterInterupts(ethereum)
+ ethereum.Start()
+
+ if StartMining {
+ log.Printf("Miner started\n")
+
+ // Fake block mining. It broadcasts a new block every 5 seconds
+ go func() {
+ pow := &ethchain.EasyPow{}
+ data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
+ keyRing := ethutil.NewValueFromBytes(data)
+ addr := keyRing.Get(1).Bytes()
+
+ for {
+ txs := ethereum.TxPool.Flush()
+ // Create a new block which we're going to mine
+ block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs)
+ // Apply all transactions to the block
+ ethereum.BlockManager.ApplyTransactions(block, block.Transactions())
+
+ ethereum.BlockManager.AccumelateRewards(block, block)
+
+ // Search the nonce
+ block.Nonce = pow.Search(block)
+ err := ethereum.BlockManager.ProcessBlock(block)
+ if err != nil {
+ log.Println(err)
+ } else {
+ log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockManager.BlockChain().CurrentBlock)
+ }
}
- }
- }()
- }
+ }()
+ }
- // Wait for shutdown
- ethereum.WaitForShutdown()
+ // Wait for shutdown
+ ethereum.WaitForShutdown()
+ }
}