main.go (845B)
1 package main 2 3 import ( 4 "flag" 5 "log" 6 "os" 7 "net/http" 8 "strings" 9 10 "defalsify.org/go-eth-proxy/rpc" 11 "defalsify.org/go-eth-proxy/store/lmdb" 12 13 ) 14 15 func main() { 16 log.SetOutput(os.Stderr) 17 dbpath := flag.String("cachepath", ".", "Path to lmdb data") 18 host := flag.String("host", "0.0.0.0", "Remote host") 19 port := flag.String("port", "8545", "Remote path") 20 flag.Parse() 21 22 db, err := lmdb.NewStore(*dbpath) 23 if err != nil { 24 log.Printf("%s", err) 25 os.Exit(1) 26 } 27 defer db.Close() 28 29 svc := rpc.NewProxyService(db) 30 h := rpc.NewBackend(svc) //svc, flag.Arg(0)) 31 prx, err := rpc.NewProxyServer(h, flag.Arg(0)) 32 if err != nil { 33 log.Printf("%s", err) 34 os.Exit(1) 35 } 36 37 srv := &http.Server{ 38 Handler: prx, 39 Addr: strings.Join([]string{*host, *port}, ":"), 40 } 41 err = srv.ListenAndServe() 42 if err != nil { 43 log.Printf("%s", err) 44 os.Exit(1) 45 } 46 }