From 56d31697d1a92356fba662d3d9e3ba970fe7fdad Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 29 Dec 2015 18:23:27 -0600 Subject: [PATCH] plasma: skeleton for main method for daemon * Uses rubbish config atm, just a place holder --- plasma.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/plasma.go b/plasma.go index 1deb9447..2118c3b2 100644 --- a/plasma.go +++ b/plasma.go @@ -1,6 +1,53 @@ package main +import ( + "flag" + "fmt" + "net" + + "google.golang.org/grpc" + "google.golang.org/grpc/grpclog" + + "li.lan/labs/plasma/lnwallet" + "li.lan/labs/plasma/rpcprotos" +) + //lightning == terrestrial plasma +var ( + rpcport = flag.Int("port", 10000, "The port for the rpc server") +) + func main() { + flag.Parse() + + // Create, and start the lnwallet, which handles the core payment channel + // logic, and exposes control via proxy state machines. + // TODO(roasbeef): accept config via cli flags, move to real config file + // afterwards + config := &lnwallet.Config{PrivatePass: []byte("hello"), DataDir: "test_wal"} + lnwallet, err := lnwallet.NewLightningWallet(config) + if err != nil { + fmt.Printf("unable to create wallet: %v\n", err) + return + } + if err := lnwallet.Startup(); err != nil { + fmt.Printf("unable to start wallet: %v\n", err) + return + } + + // Initialize, and register our implementation of the gRPC server. + var opts []grpc.ServerOption + rpcServer := newRpcServer(lnwallet) + grpcServer := grpc.NewServer(opts...) + lnrpc.RegisterLightningServer(grpcServer, rpcServer) + + // Finally, start the grpc server listening for HTTP/2 connections. + lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *rpcport)) + if err != nil { + grpclog.Fatalf("failed to listen: %v", err) + fmt.Printf("failed to listen: %v", err) + return + } + grpcServer.Serve(lis) }