Official Go implementation of the Ethereum protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-ethereum/ethereum.go

69 lines
1.2 KiB

11 years ago
package main
import (
"fmt"
11 years ago
"os"
"os/signal"
"flag"
11 years ago
"runtime"
11 years ago
)
const Debug = true
11 years ago
var StartDBQueryInterface bool
11 years ago
var StartMining bool
func Init() {
flag.BoolVar(&StartDBQueryInterface, "db", false, "start db query interface")
11 years ago
flag.BoolVar(&StartMining, "mine", false, "start dagger mining")
flag.Parse()
}
11 years ago
// 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 {
11 years ago
fmt.Printf("Shutting down (%v) ... \n", sig)
11 years ago
s.Stop()
}
}()
}
11 years ago
func main() {
11 years ago
runtime.GOMAXPROCS(runtime.NumCPU())
11 years ago
InitFees()
Init()
11 years ago
if StartDBQueryInterface {
dbInterface := NewDBInterface()
dbInterface.Start()
11 years ago
} else if StartMining {
dagger := &Dagger{}
seed := dagger.Search(BigPow(2, 36))
fmt.Println("dagger res = ", seed)
} else {
11 years ago
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()
}
11 years ago
}