Problems when starting peerswapd
Background
Failure in peerswapd startup depending on lnd startup status. Sometimes hangs indefinitely and sometimes the process is terminated.
Hangs indefinitely
It occurs when the lnd gRPC server is not up. Hangs while waiting for DialContext to connect.
Reason
Because the DialContext is running in blocking mode and there is no context timeout.
Plan for improvement
I think it could have a certain time limit, and if it can't connect, it could output a log and terminate.
Process terminated
Occurs when unable to connect to lnd server.
[INFO] PeerSwap LND starting up with commit 600c73d8600c8bdf6226edf027cd9578e24e3978 and cfg: Host localhost:42069, ConfigFile peerswap.conf, Datadir .peerswap, Bitcoin enabled: true, Lnd Config: host: localhost:10009, macaroonpath admin.macaroon, tlspath tls.cert, elements: elements: rpcuser: admin1, rpchost: http://127.0.0.1/, rpcport 18884, rpcwallet: swaplnd, liquidswaps: true
2024/01/10 08:06:41 [INFO] DB version: v0.2, Protocol version: 3
2024/01/10 08:06:42 [DEBUG] [grpc_conn]: grpc_retry attempt: 0, got err: rpc error: code = Unknown desc = waiting to start, RPC services not available
Reason
When the error occurs, the process of peerswapd is terminated immediately without retry.
plan for improvement
When the said error occurs, how about trying to retry a certain number of times, since it is likely to be recovered by retrying?
RetryCodesWithMsg containing waiting to start, RPC services not available, etc.