daemon: fix wrapped errors and typos

Slyghtning 3 weeks ago
parent cd5dc903f9
commit dec5a6dc5d
No known key found for this signature in database
GPG Key ID: F82D456EA023C9BF

@ -53,7 +53,7 @@ type ListenerCfg struct {
// on the passed TLS configuration. // on the passed TLS configuration.
restListener func(*tls.Config) (net.Listener, error) restListener func(*tls.Config) (net.Listener, error)
// getLnd returns a grpc connection to an lnd instance. // getLnd returns a grpc connection to a lnd instance.
getLnd func(lndclient.Network, *lndConfig) (*lndclient.GrpcLndServices, getLnd func(lndclient.Network, *lndConfig) (*lndclient.GrpcLndServices,
error) error)
} }
@ -120,9 +120,9 @@ func New(config *Config, lisCfg *ListenerCfg) *Daemon {
// Start starts loopd in daemon mode. It will listen for grpc connections, // Start starts loopd in daemon mode. It will listen for grpc connections,
// execute commands and pass back swap status information. // execute commands and pass back swap status information.
func (d *Daemon) Start() error { func (d *Daemon) Start() error {
// There should be no reason to start the daemon twice. Therefore return // There should be no reason to start the daemon twice. Therefore,
// an error if that's tried. This is mostly to guard against Start and // return an error if that's tried. This is mostly to guard against
// StartAsSubserver both being called. // Start and StartAsSubserver both being called.
if atomic.AddInt32(&d.started, 1) != 1 { if atomic.AddInt32(&d.started, 1) != 1 {
return errOnlyStartOnce return errOnlyStartOnce
} }
@ -137,7 +137,7 @@ func (d *Daemon) Start() error {
// With lnd connected, initialize everything else, such as the swap // With lnd connected, initialize everything else, such as the swap
// server client, the swap client RPC server instance and our main swap // server client, the swap client RPC server instance and our main swap
// and error handlers. If this fails, then nothing has been started yet // and error handlers. If this fails, then nothing has been started yet,
// and we can just return the error. // and we can just return the error.
err = d.initialize(true) err = d.initialize(true)
if errors.Is(err, bbolt.ErrTimeout) { if errors.Is(err, bbolt.ErrTimeout) {
@ -324,7 +324,7 @@ func (d *Daemon) startWebServers() error {
err := d.restServer.Serve(d.restListener) err := d.restServer.Serve(d.restListener)
// ErrServerClosed is always returned when the proxy is // ErrServerClosed is always returned when the proxy is
// shut down, so don't log it. // shut down, so don't log it.
if err != nil && err != http.ErrServerClosed { if err != nil && !errors.Is(http.ErrServerClosed, err) {
// Notify the main error handler goroutine that // Notify the main error handler goroutine that
// we exited unexpectedly here. We don't have to // we exited unexpectedly here. We don't have to
// worry about blocking as the internal error // worry about blocking as the internal error
@ -343,7 +343,7 @@ func (d *Daemon) startWebServers() error {
log.Infof("RPC server listening on %s", d.grpcListener.Addr()) log.Infof("RPC server listening on %s", d.grpcListener.Addr())
err = d.grpcServer.Serve(d.grpcListener) err = d.grpcServer.Serve(d.grpcListener)
if err != nil && err != grpc.ErrServerStopped { if err != nil && !errors.Is(err, grpc.ErrServerStopped) {
// Notify the main error handler goroutine that // Notify the main error handler goroutine that
// we exited unexpectedly here. We don't have to // we exited unexpectedly here. We don't have to
// worry about blocking as the internal error // worry about blocking as the internal error
@ -682,9 +682,9 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
var runtimeErr error var runtimeErr error
// There are only two ways this goroutine can exit. Either there // There are only two ways this goroutine can exit. Either there
// is an internal error or the caller requests shutdown. In both // is an internal error or the caller requests a shutdown.
// cases we wait for the stop to complete before we signal the // In both cases we wait for the stop to complete before we
// caller that we're done. // signal the caller that we're done.
select { select {
case runtimeErr = <-d.internalErrChan: case runtimeErr = <-d.internalErrChan:
log.Errorf("Runtime error in daemon, shutting down: "+ log.Errorf("Runtime error in daemon, shutting down: "+
@ -693,7 +693,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
case <-d.quit: case <-d.quit:
} }
// We need to shutdown before sending the error on the channel, // We need to shut down before sending the error on the channel,
// otherwise a caller might exit the process too early. // otherwise a caller might exit the process too early.
d.stop() d.stop()
cleanupMacaroonStore() cleanupMacaroonStore()
@ -724,7 +724,7 @@ func (d *Daemon) stop() {
d.mainCtxCancel() d.mainCtxCancel()
} }
// As there is no swap activity anymore, we can forcefully shutdown the // As there is no swap activity anymore, we can forcefully shut down the
// gRPC and HTTP servers now. // gRPC and HTTP servers now.
log.Infof("Stopping gRPC server") log.Infof("Stopping gRPC server")
if d.grpcServer != nil { if d.grpcServer != nil {

Loading…
Cancel
Save