lnd: rename light client cmd line option to `--neutrino.X=K`

This commit is contained in:
Olaoluwa Osuntokun 2017-06-05 15:44:18 -07:00
parent aec8c8dc77
commit 4b29c70c45
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
3 changed files with 14 additions and 11 deletions

View File

@ -100,7 +100,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl
// If spv mode is active, then we'll be using a distimnct set of // If spv mode is active, then we'll be using a distimnct set of
// chainControl interfaces that interface directly with the p2p network // chainControl interfaces that interface directly with the p2p network
// of the selected chain. // of the selected chain.
if cfg.SpvMode.Active { if cfg.NeutrinoMode.Active {
// First we'll open the database file for neutrino, creating // First we'll open the database file for neutrino, creating
// the database if needed. // the database if needed.
dbName := filepath.Join(cfg.DataDir, "neutrino.db") dbName := filepath.Join(cfg.DataDir, "neutrino.db")
@ -116,8 +116,8 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl
DataDir: cfg.DataDir, DataDir: cfg.DataDir,
Database: nodeDatabase, Database: nodeDatabase,
ChainParams: *activeNetParams.Params, ChainParams: *activeNetParams.Params,
AddPeers: cfg.SpvMode.AddPeers, AddPeers: cfg.NeutrinoMode.AddPeers,
ConnectPeers: cfg.SpvMode.ConnectPeers, ConnectPeers: cfg.NeutrinoMode.ConnectPeers,
} }
neutrino.WaitForMoreCFHeaders = time.Second * 1 neutrino.WaitForMoreCFHeaders = time.Second * 1
neutrino.MaxPeers = 8 neutrino.MaxPeers = 8

View File

@ -58,7 +58,7 @@ type chainConfig struct {
SimNet bool `long:"simnet" description:"Use the simulation test network"` SimNet bool `long:"simnet" description:"Use the simulation test network"`
} }
type spvConfig struct { type neutrinoConfig struct {
Active bool `long:"active" destination:"If SPV mode should be active or not."` Active bool `long:"active" destination:"If SPV mode should be active or not."`
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"` AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"`
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"` ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
@ -93,7 +93,7 @@ type config struct {
Litecoin *chainConfig `group:"Litecoin" namespace:"litecoin"` Litecoin *chainConfig `group:"Litecoin" namespace:"litecoin"`
Bitcoin *chainConfig `group:"Bitcoin" namespace:"bitcoin"` Bitcoin *chainConfig `group:"Bitcoin" namespace:"bitcoin"`
SpvMode *spvConfig `group:"SPV" namespace:"spv"` NeutrinoMode *neutrinoConfig `group:"neutrino" namespace:"neutrino"`
} }
// loadConfig initializes and parses the config using a config file and command // loadConfig initializes and parses the config using a config file and command
@ -180,7 +180,7 @@ func loadConfig() (*config, error) {
// The SPV mode implemented currently doesn't support Litecoin, so the // The SPV mode implemented currently doesn't support Litecoin, so the
// two modes are incompatible. // two modes are incompatible.
if cfg.SpvMode.Active && cfg.Litecoin.Active { if cfg.NeutrinoMode.Active && cfg.Litecoin.Active {
str := "%s: The light client mode currently supported does " + str := "%s: The light client mode currently supported does " +
"not yet support execution on the Litecoin network" "not yet support execution on the Litecoin network"
err := fmt.Errorf(str, funcName) err := fmt.Errorf(str, funcName)
@ -201,7 +201,7 @@ func loadConfig() (*config, error) {
applyLitecoinParams(&paramCopy) applyLitecoinParams(&paramCopy)
activeNetParams = paramCopy activeNetParams = paramCopy
if !cfg.SpvMode.Active { if !cfg.NeutrinoMode.Active {
// Attempt to parse out the RPC credentials for the // Attempt to parse out the RPC credentials for the
// litecoin chain if the information wasn't specified // litecoin chain if the information wasn't specified
err := parseRPCParams(cfg.Litecoin, litecoinChain, funcName) err := parseRPCParams(cfg.Litecoin, litecoinChain, funcName)
@ -237,7 +237,7 @@ func loadConfig() (*config, error) {
return nil, err return nil, err
} }
if !cfg.SpvMode.Active { if !cfg.NeutrinoMode.Active {
// If needed, we'll attempt to automatically configure // If needed, we'll attempt to automatically configure
// the RPC control plan for the target btcd node. // the RPC control plan for the target btcd node.
err := parseRPCParams(cfg.Bitcoin, bitcoinChain, funcName) err := parseRPCParams(cfg.Bitcoin, bitcoinChain, funcName)

9
lnd.go
View File

@ -102,6 +102,8 @@ func lndMain() error {
return err return err
} }
// Next, we'll initialize the funding manager itself so it can answer
// queries while the wallet+chain are still syncing.
nodeSigner := newNodeSigner(idPrivKey) nodeSigner := newNodeSigner(idPrivKey)
var chanIDSeed [32]byte var chanIDSeed [32]byte
if _, err := rand.Read(chanIDSeed[:]); err != nil { if _, err := rand.Read(chanIDSeed[:]); err != nil {
@ -159,16 +161,17 @@ func lndMain() error {
} }
server.fundingMgr = fundingMgr server.fundingMgr = fundingMgr
// Initialize, and register our implementation of the gRPC server. // Initialize, and register our implementation of the gRPC interface
var opts []grpc.ServerOption // exported by the rpcServer.
rpcServer := newRPCServer(server) rpcServer := newRPCServer(server)
if err := rpcServer.Start(); err != nil { if err := rpcServer.Start(); err != nil {
return err return err
} }
var opts []grpc.ServerOption
grpcServer := grpc.NewServer(opts...) grpcServer := grpc.NewServer(opts...)
lnrpc.RegisterLightningServer(grpcServer, rpcServer) lnrpc.RegisterLightningServer(grpcServer, rpcServer)
// Next, Start the grpc server listening for HTTP/2 connections. // Next, Start the gRPC server listening for HTTP/2 connections.
grpcEndpoint := fmt.Sprintf("localhost:%d", loadedConfig.RPCPort) grpcEndpoint := fmt.Sprintf("localhost:%d", loadedConfig.RPCPort)
lis, err := net.Listen("tcp", grpcEndpoint) lis, err := net.Listen("tcp", grpcEndpoint)
if err != nil { if err != nil {