Skip to content

Commit

Permalink
Add timout dialing lnd
Browse files Browse the repository at this point in the history
  • Loading branch information
Impa10r committed Jan 14, 2025
1 parent 3e818da commit ded4ddc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"program": "${workspaceFolder}/cmd/psweb/",
"showLog": false,
//"envFile": "${workspaceFolder}/.env",
"args": ["-datadir", "/home/vlad/.peerswap_t4"]
//"args": ["-datadir", "/home/vlad/.peerswap_t4"]
//"args": ["-datadir", "/home/vlad/.peerswap2"]
},
// sudo bash -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Fix BTC to sats rounding bug preventing claim init or join
- Fix external funding peg-in num of confirmations not registered
- Fix ClaimJoin OP_RETURN string
- Add timout dialing lnd
- Wait for lightning to sync before subscribing

## 1.7.5
Expand Down
8 changes: 5 additions & 3 deletions cmd/psweb/ln/lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ func lndConnection() (*grpc.ClientConn, error) {
grpc.WithPerRPCCredentials(macCred),
}

conn, err := grpc.Dial(host, opts...)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

conn, err := grpc.DialContext(ctx, host, opts...)
if err != nil {
fmt.Println("lndConnection dial:", err)
return nil, err
}

Expand Down Expand Up @@ -1185,7 +1187,7 @@ func DownloadAll() bool {
ctx := context.Background()

if MyNodeId == "" {
res, err := client.GetInfo(context.Background(), &lnrpc.GetInfoRequest{})
res, err := client.GetInfo(ctx, &lnrpc.GetInfoRequest{})
if err != nil {
// lnd not ready
return false
Expand Down
4 changes: 2 additions & 2 deletions cmd/psweb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func startTimer() {
onTimer()

// then every minute
for range time.Tick(60 * time.Second) {
for range time.Tick(time.Minute) {
onTimer()
}
}
Expand Down Expand Up @@ -457,7 +457,7 @@ func setLogging(logFileName string) (func(), error) {
}

// add new line after start up
log.Println("------------------START-----------------")
log.Printf("------------------START %s-----------------", VERSION)

return cleanup, nil
}
Expand Down

0 comments on commit ded4ddc

Please sign in to comment.