aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-01-10 07:39:16 +0800
committerobscuren <geffobscura@gmail.com>2014-01-10 07:39:16 +0800
commitbd0abe2a8187c0ae948bba6a90cbaac07f479cc8 (patch)
treecf3fea9cb3cc09d75609aaffe11374f7e9a72d8b /ethereum.go
parent849408dda60fe32d7abb78d103b09ca0bc7b5a60 (diff)
downloaddexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.tar
dexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.tar.gz
dexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.tar.bz2
dexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.tar.lz
dexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.tar.xz
dexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.tar.zst
dexon-bd0abe2a8187c0ae948bba6a90cbaac07f479cc8.zip
Updated server and peers and mining processing
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go31
1 files changed, 24 insertions, 7 deletions
diff --git a/ethereum.go b/ethereum.go
index e3e5005eb..6ceb0249d 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -6,6 +6,7 @@ import (
"os/signal"
"flag"
"runtime"
+ "log"
_"math/big"
)
@@ -45,23 +46,39 @@ func main() {
if StartConsole {
console := NewConsole()
console.Start()
- } else if StartMining {
- dagger := &Dagger{}
- res := dagger.Search(BigPow(2, 36))
- fmt.Println("nonce =", res)
- } else {
- fmt.Println("[DBUG]: Starting Ethereum")
+ } else{
+ log.Println("Starting Ethereum")
server, err := NewServer()
if err != nil {
- fmt.Println("error NewServer:", err)
+ log.Println(err)
return
}
RegisterInterupts(server)
+ if StartMining {
+ log.Println("Mining started")
+ dagger := &Dagger{}
+
+ go func() {
+ for {
+ res := dagger.Search(Big("0"), BigPow(2, 36))
+ server.Broadcast("foundblock", res.Bytes())
+ }
+ }()
+ }
+
server.Start()
+ err = server.ConnectToPeer("localhost:12345")
+ if err != nil {
+ log.Println(err)
+ server.Stop()
+ return
+ }
+
+
// Wait for shutdown
server.WaitForShutdown()
}