github.com/prysmaticlabs/prysm@v1.4.4/tools/faucet/main.go (about)

     1  package main
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"net"
     7  
     8  	"github.com/prestonvanloon/go-recaptcha"
     9  	faucetpb "github.com/prysmaticlabs/prysm/proto/faucet"
    10  	_ "github.com/prysmaticlabs/prysm/shared/maxprocs"
    11  	"google.golang.org/grpc"
    12  	"google.golang.org/grpc/reflection"
    13  )
    14  
    15  var (
    16  	port            = flag.Int("port", 8000, "Port to server gRPC service")
    17  	recaptchaSecret = flag.String("recaptcha_secret", "", "Secret to verify recaptcha")
    18  	rpcPath         = flag.String("rpc", "", "RPC address of a running geth node")
    19  	privateKey      = flag.String("private-key", "", "The private key of funder")
    20  	minScore        = flag.Float64("min-score", 0.9, "Minimum captcha score.")
    21  )
    22  
    23  func main() {
    24  	flag.Parse()
    25  
    26  	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
    27  	if err != nil {
    28  		panic(err)
    29  	}
    30  	s := grpc.NewServer()
    31  	fmt.Println("recaptcha = " + *recaptchaSecret)
    32  	faucetpb.RegisterFaucetServiceServer(s,
    33  		newFaucetServer(
    34  			recaptcha.Recaptcha{RecaptchaPrivateKey: *recaptchaSecret},
    35  			*rpcPath,
    36  			*privateKey,
    37  			*minScore,
    38  		),
    39  	)
    40  
    41  	reflection.Register(s)
    42  	go counterWatcher()
    43  
    44  	fmt.Printf("Serving gRPC requests on port %d\n", *port)
    45  	if err := s.Serve(lis); err != nil {
    46  		fmt.Printf("Error: %v", err)
    47  	}
    48  }