commit 8b65148a64df3a0f26676e1e0719fbf112db7d58
parent 64d7848eda51711e04e44d8d94a9d6a67e67931c
Author: William Casarin <jb55@jb55.com>
Date: Thu, 28 Jul 2022 12:03:48 -0700
respond to pings
Changelog-Added: Respond to pings for long requests
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lightninglink/LNSocket.swift b/lightninglink/LNSocket.swift
@@ -64,6 +64,12 @@ public class LNSocket {
return (msgtype, data)
}
+
+ func pong(ping: Data) {
+ ping.withUnsafeBytes{ ping_ptr in
+ lnsocket_pong(self.ln, ping_ptr, UInt16(ping.count))
+ }
+ }
func perform_init() -> Bool {
return lnsocket_perform_init(self.ln) != 0
diff --git a/lightninglink/RPC.swift b/lightninglink/RPC.swift
@@ -340,6 +340,9 @@ func commando_read_all(ln: LNSocket, timeout_ms: Int32 = 2000) -> RequestRes<Dat
} else if msgtype == COMMANDO_REPLY_CONTINUES {
all_data.append(data[8...])
continue
+ } else if msgtype == WIRE_PING.rawValue {
+ // respond to pings for long requests like waitinvoice, etc
+ ln.pong(ping: data)
} else {
//return .failure(RequestError(errorType: .badCommandoMsgType(Int(msgtype))))
// we could get random messages like channel update! just ignore them