2013-12-26 03:45:52 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2013-12-29 14:53:20 -08:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
2014-01-01 04:37:00 -08:00
|
|
|
"flag"
|
2014-01-08 14:43:20 -08:00
|
|
|
"runtime"
|
2014-01-09 02:57:35 -08:00
|
|
|
_"math/big"
|
2013-12-26 03:45:52 -08:00
|
|
|
)
|
|
|
|
|
2013-12-31 18:07:49 -08:00
|
|
|
const Debug = true
|
2013-12-28 06:18:23 -08:00
|
|
|
|
2014-01-01 04:37:00 -08:00
|
|
|
var StartDBQueryInterface bool
|
2014-01-08 14:43:20 -08:00
|
|
|
var StartMining bool
|
2014-01-01 04:37:00 -08:00
|
|
|
func Init() {
|
2014-01-09 02:57:35 -08:00
|
|
|
flag.BoolVar(&StartDBQueryInterface, "c", false, "console interface")
|
2014-01-08 14:43:20 -08:00
|
|
|
flag.BoolVar(&StartMining, "mine", false, "start dagger mining")
|
2014-01-01 04:37:00 -08:00
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
2013-12-29 14:53:20 -08:00
|
|
|
// Register interrupt handlers so we can stop the server
|
|
|
|
func RegisterInterupts(s *Server) {
|
|
|
|
// Buffered chan of one is enough
|
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
// Notify about interrupts for now
|
|
|
|
signal.Notify(c, os.Interrupt)
|
|
|
|
go func() {
|
|
|
|
for sig := range c {
|
2014-01-08 14:43:20 -08:00
|
|
|
fmt.Printf("Shutting down (%v) ... \n", sig)
|
2013-12-29 14:53:20 -08:00
|
|
|
|
|
|
|
s.Stop()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2013-12-26 03:45:52 -08:00
|
|
|
func main() {
|
2014-01-08 14:43:20 -08:00
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
|
2013-12-26 03:45:52 -08:00
|
|
|
InitFees()
|
|
|
|
|
2014-01-01 04:37:00 -08:00
|
|
|
Init()
|
2013-12-26 03:45:52 -08:00
|
|
|
|
2014-01-01 04:37:00 -08:00
|
|
|
if StartDBQueryInterface {
|
|
|
|
dbInterface := NewDBInterface()
|
|
|
|
dbInterface.Start()
|
2014-01-08 14:43:20 -08:00
|
|
|
} else if StartMining {
|
|
|
|
dagger := &Dagger{}
|
2014-01-09 02:57:35 -08:00
|
|
|
dagger.Search(BigPow(2, 36))
|
2014-01-01 04:37:00 -08:00
|
|
|
} else {
|
2014-01-08 14:43:20 -08:00
|
|
|
fmt.Println("[DBUG]: Starting Ethereum")
|
|
|
|
server, err := NewServer()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("error NewServer:", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
RegisterInterupts(server)
|
|
|
|
|
|
|
|
server.Start()
|
|
|
|
|
|
|
|
// Wait for shutdown
|
|
|
|
server.WaitForShutdown()
|
2014-01-01 04:37:00 -08:00
|
|
|
}
|
2013-12-26 03:45:52 -08:00
|
|
|
}
|