diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-22 06:27:08 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-22 06:27:08 +0800 |
commit | 3616080db46931202003157bacf10748008bebc0 (patch) | |
tree | a2004c7c4c8f6c91999b734b75a57ac31b04cb97 /ethereum.go | |
parent | e47230f82da93ef0110faa76211b9b6f13b1060b (diff) | |
download | dexon-3616080db46931202003157bacf10748008bebc0.tar.gz dexon-3616080db46931202003157bacf10748008bebc0.tar.zst dexon-3616080db46931202003157bacf10748008bebc0.zip |
Added synchronisation of transactions across remote pools
Diffstat (limited to 'ethereum.go')
-rw-r--r-- | ethereum.go | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/ethereum.go b/ethereum.go index d74cb4ff2..b7f059a02 100644 --- a/ethereum.go +++ b/ethereum.go @@ -7,6 +7,7 @@ import ( "log" "os" "os/signal" + "path" "runtime" ) @@ -44,36 +45,54 @@ func main() { Init() + ethutil.ReadConfig() + + server, err := NewServer() + + if err != nil { + log.Println(err) + return + } + if StartConsole { - console := NewConsole() - console.Start() - } else { - log.Println("Starting Ethereum") - server, err := NewServer() + err := os.Mkdir(ethutil.Config.ExecPath, os.ModePerm) + // Error is OK if the error is ErrExist + if err != nil && !os.IsExist(err) { + log.Panic("Unable to create EXECPATH. Exiting") + } + // TODO The logger will eventually be a non blocking logger. Logging is a expensive task + // Log to file only + file, err := os.OpenFile(path.Join(ethutil.Config.ExecPath, "debug.log"), os.O_RDWR|os.O_CREATE, os.ModePerm) if err != nil { - log.Println(err) - return + log.Panic("Unable to set proper logger", err) } - RegisterInterupts(server) + ethutil.Config.Log = log.New(file, "", 0) - if StartMining { - log.Println("Mining started") - dagger := &Dagger{} + console := NewConsole(server) + go console.Start() + } - go func() { - for { - res := dagger.Search(ethutil.Big("01001"), ethutil.BigPow(2, 36)) - log.Println("Res dagger", res) - //server.Broadcast("blockmine", ethutil.Encode(res.String())) - } - }() - } + log.Println("Starting Ethereum") + + RegisterInterupts(server) - server.Start() + if StartMining { + log.Println("Mining started") + dagger := &Dagger{} - // Wait for shutdown - server.WaitForShutdown() + go func() { + for { + res := dagger.Search(ethutil.Big("01001"), ethutil.BigPow(2, 36)) + log.Println("Res dagger", res) + //server.Broadcast("blockmine", ethutil.Encode(res.String())) + } + }() } + + server.Start() + + // Wait for shutdown + server.WaitForShutdown() } |